dhh1128 / intent

the intent formal language
https://intentlang.org
2 stars 1 forks source link

Support a scope changer #97

Open dhh1128 opened 9 years ago

dhh1128 commented 9 years ago

VB used to have a "with" statement (not to be confused with python's "with" statement) that made it unnecessary to repeatedly type the same object deref/scope walking text. Consider the following exceedingly redundant code:

pSettings->bIgnoreDirectoryForLinks = a;
pSettings->bIncludeSelectionLists = b;
pSettings->iMinCJKnGramLength = c;
pSettings->iMaxCJKnGramLength = d;
pSettings->bUsePrefixForMeta = e;
pSettings->bUsePrefixForTitle = f;
pSettings->bUsePrefixForLinks = g;
pSettings->bUsePrefixForForm = h;
pSettings->bUsePrefixForAlt = i;
pSettings->bUsePrefixForLinkText = j;

Wouldn't it be better to do something like this:

with pSettings:
    bIgnoreDirectoryForLinks = a;
    bIncludeSelectionLists = b;
    iMinCJKnGramLength = c;
    iMaxCJKnGramLength = d;
    bUsePrefixForMeta = e;
    bUsePrefixForTitle = f;
    bUsePrefixForLinks = g;
    bUsePrefixForForm = h;
    bUsePrefixForAlt = i;
    bUsePrefixForLinkText = j;

We'd have to deal with the semantics being different from python's "with" statement. An alternative keyword might be "inside" or "in scope of".