[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Semantics of let



I include below the reply to my message I sent to Paul.

---

I use this sequential binding quite often, it saves me typing lots of nested
lets/locals, so personally I'd rather not have its semantics changed :-).
I think it's rather intuitive having ``;'' mean sequential composition.

Paul writes
> this is, of course, the reason that the semantics are they way they are
> right now.  of course, you can do
> 
> 	let (x = ...) let (y = ...) cmd
> 
> without the other braces, but it isn't pretty.  the verdict's not in yet.

Anyway, wouldn't the other behaviour be achievable when multiple-assignment
arrives? Ie,
	; foo = foo; bar = bar
	; let ((foo bar) = ($bar $foo)) echo $foo $bar
	bar foo

Paul writes
> no.  remember that es has no hierarchical lists.
> 
> 	; a = foo bar
> 	; b = baz
> 	; let ((x y) = ($a $b)) echo $x -- $y
> 	foo -- bar baz
> 	; 

To make ``for'' consistent with let and local, couldn't we make the current
behaviour the semantics for multiple assignment in the for-binding, and
single-assignment would give a sequential binding, eg
	; for (i = a b; j = 1 2) echo $i $j
equivalent to
	; for (i = a b) for(j = 1 2) echo $i $j

Paul writes
> again, the absence of hierarchical lists gets in the way.  besides,
> i have semantics i like for multiple-assignment based for:
> 
> 	; for (i j = 1 2 3 4) echo $i $j
> 	1 2
> 	3 4
> 	; 
> 
> it's gratuitous, but it falls right out of everything that's already
> there.