(f value: n) <=> f{n}

Mats Nygren nygren at sics.se
Sat Jul 8 13:57:53 UTC 2000


Marcel Weiher <marcel at metaobject.com> wrote:
> How about
> 
> 	n f.
> 
> instead?  Wouldn't that be more in the 'spirit' of Smalltalk?
> [snip]

IMO, the present {}-construction in Squeak is not necessarily in the
spirit of Smalltalk, no receiver, no identifiable selector. My thought
was this, consider
  { 1. 2 }
a message send to Array:
  Array { 1. 2 }
with 'Array' implicit.

It remains to explain which message it is and after having become
bored with seeing value:-messages for a while I decided to try the idea
of identifying the invisible {}-message with the value:-series of messages.
Since this was easy and is useful I am trying it out now. It also looks like
functional application.

What you are saying in the rest of your message is interesting and I will
take a look at it if you implement it. As far as I can see it lacks the immediate
and effortless implementability of the brace-message.

Some example uses:
with appropriate definitions of valueWithArguments::
"#at: == #value: for arrays"
the rest are for guessing

Set { x. y. z } size "the number of different"
SortedCollection { x. y. z } { 1 } "the least"
Dictionary { x1->y1. x2->y2 }
#printString { x+y } "<=> (x+y) printString"
etc
{[expression one]. [expression two]} {i} {} 
(x < y) {[expression one]. [expression two]}
String { 'x: '. x. 'y: ' y } "gives 'x: 12 y: 13' if x=12 y=13"

> [snip]
> However, isn't that really just a special case?  Isn't the  
> Symbol/Message just a specific instance of the 'Valuable' protocol,  
> that is, things that (should) respond to #value:* ?  So maybe,  
> anything that responds to valuable protocol should be able to take  
> that spot in a message expression.

This will create another language than ST-80, it should be possible
to have that in the same image in a well designed environment.

> The idea actually crept up on me in a different context, my old  
> favorite the trampoline-based higher-order messages, and how to  
> integrate them with the block mechanism, seeing how they cannot  
> really replace blocks for all purposes.

Can you give me some pointers to the trampoline stuff? I know there are
postings on this but I never found them in the archives.

> So maybe one could write a block  [ :each | each doSomething ]  
> simply as  [ doSomething ], and use it in the same place as a normal  
> message.
> 
> 	myCollection do [ doSomething ].

try

  myCollection do {[ :each | each doSomething ]}

and implement value: appropriately for whatever do produces

Or perhaps I misunderstood, is 'doSomething' a symbol or any code?

> Before everybody yells  bloody murder, I know that there are  
> problems with this, it is just an intermediate idea.

intermediate idea's are great considering final ideas

> [snip]
> One major difficulty is dealing with keyword messages, although I  
> haven't really put much effort into trying to find a solution.

On important part of this is collecting several arguments, the
{}-construction captures that.

> Technical comments

Interesting.

> and suggestions welcomes, 

Try combining it with Craig Latta's streaming machinery that is being
ported to Squeak.

Think about how it will fit together with Dan Ingall's Fabrik.

> syntax-war flames to  /dev/null or to me personally.

At SICS we have a special mail address: devnull at sics.se :-)

I will appreciate your comments on my next posting about functional
squeak, "more value (functional squeak)".

As you probably know I want Squeak to be organized to make different
language variants such as yours easy to try out. By separating the
syntactic part of that from the semantic.

/Mats





More information about the Squeak-dev mailing list