On Thu, Aug 4, 2011 at 22:32, Martin <[email protected]> wrote: > IF something like alias were to be introduced (and I am *not* for this), > then pascal style, with a declaration above the code. It could then be used > in a "with" statement, or anywhere else. > > procedure foo; > var > c: TObject; alias; > begin > > OR > procedure foo; > alias > c: TObject; > begin > > > and then > with c = SomeFoo do c.DoBar
That would defeat the whole purpose of the aliases vs variables, which is to avoid junk declaration. > Of course, the question is why? IT had to be defined where the difference to > a normal variable is? Aliases should not be declared, only defined. > So currently "With" does NOT save a variable (it only saves the reader from > spotting the variable). Of course. > On the other hand, if it truely was an alias, then if it was set to an > expression: > with c = SumeFuncWithSideEffects(1,2,3) do begin > c.DoBar; > c.DoOther; > end; > > should c expand each time, and call the function (with side effects) or > should c alias the result. And how could one (as programmer) express, if one > wants to allias the function-call (including specific param list), or the > result ? Alias should behave like variable (or, rather, constant), except it should not require declaration. > So aliases, if existent could be used in "with" but are not something > special to (or limited to) "with". Aliases would be a generic thing (pretty > much like "absolute", only they can be set to alias difference things in the > code block). Maybe, but the difference between with a := MuFunc do begin .. end; and alias a := MuFunc; is that in the former case the scope of the alias is explicitly limited to the 'with' statement, which I think better suits Pascal style (and also has very good analogy to the 'let' statement in Haskell and other functional languages). As an aside, note that using "=" instead of ":=" is impossible due to syntax ambiguity -- "with a = b do" is already a valid syntax. -- Alexander S. Klenin -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
