[e-lang] Proposed grammar simplifications

David Hopwood david.nospam.hopwood at blueyonder.co.uk
Wed Jun 1 10:41:25 EDT 2005


Mark Miller wrote:
> David Hopwood wrote:
> 
>> [...] "foo with= (3)" is hardly enough shorter than "foo := foo.with(3)"
>> to justify this sugar at all.
> 
> Assuming Dean can make it work in the Antlr grammar, it looks like we 
> will preserve the current ability to leave off these parens. But for the 
> record...
> 
> Keep in mind that 'foo' above may be an expression.

I know, but for the assignment to make sense it must be an lvalue
expression (if you'll forgive the C'ism). Usually lvalue expressions
are short and don't have side effects. If the expression is longer or
does have side effects, then it's almost certainly better to introduce
a temporary variable, with a name that explains what it is supposed to
mean (http://www.modelmakertools.com/articles/introduce-explaining-var.html).

>> How frequent are cases like "bar with= (key, value)"?
> 
> We hope to encourage a style of programming with mutable variables 
> holding immutable collections, rather than immutable variables holding 
> mutable collections. Should this style actually catch on, the above case 
> would be quite common.

OK, point taken.

-- 
David Hopwood <david.nospam.hopwood at blueyonder.co.uk>



More information about the e-lang mailing list