On Jun 30, 2015, at 6:43 PM, George Neuner wrote:

> On 6/30/2015 5:34 PM, 'John Clements' via Racket Users wrote:
>> > On Jun 30, 2015, at 8:10 AM, Alexey Cherkaev <alexey.cherk...@gmail.com> 
>> > wrote:
>> >
>> > ... wouldn't it be beneficial to have such a generalised 'set!' 
>> > system-wide? I understand that Racket focusses more on immutable 
>> > structures, but there are still vectors and hash-tables which are 
>> > inherently mutable and still have their niche.
>> 
>> This style of set! seems like a bad idea to me.
>> 
>> Specifically, one of the basic ideas of algebraic languages is that programs 
>> are compositional. Specifically, if I write (a (b x) c), then the meaning of 
>> this term depends on the meanings of a, (b x), and c. That is, I can combine 
>> these three values to get the result. Generalized set! breaks this 
>> intuition. Specifically, (set! (aref x 0 1) 13) does not depend on the value 
>> of (aref x 0 1). Rather, it pulls apart this term and uses its subterm’s 
>> meanings. Put differently, this is lvalues.
>> 
>> I know, I know, I sound like a pure-functional snooty-poo.
> 
> Don't confuse source syntax with what goes on under the hood - compilers for 
> imperative languages often go to great lengths to transform programs into 
> more "functional" forms.  Search for "value numbering" and "static single 
> assignment" for more information. [Those aren't the only functionalizing 
> transformations, but they are the most commonly used.]
> 
> Moreover, assignment per se is not incompatible with composition - that's 
> just semantics.  On real hardware, assignment is all you have: "binding" is 
> implemented as assignment to a (possibly) new location.  Tail recursion is an 
> important case of invisibly "binding" new values to the same locations (i.e. 
> assigning to the control variables of an imperative loop).



John knows these things. His advisor co-invented SSA and preached the 
imperative-compilers-are-functional while he was in grad school. I know, I was 
there and watched, and I know the guy. I am sure it all sank in. 

What you fail to see is that "it's just semantics" is a way of saying "why 
bother programming in languages such as Racket or ML or Coq. It's all 
assignment statements on the machine anyway." As we know from many years of 
experience of course is that this statement makes no sense to a good 
programmer. There are huge differences. And what John is getting at is that the 
language (as is) carries its meaning and its pragmatics on its sleeves. The 
very moment you introduce the kind of generalized assignment statement you lose 
this kind of clarity that comes with the language. 

So let's all be happy now and program in ASM. It's assignments anyway and LHS 
values are lovely for the heart-ware purist  :-) 

-- Matthias

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to