Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Richard O Keefe
Last updated at 1:39 pm UTC on 16 January 2006
"David N. Smith (IBM)" pointed out:
HeadMorph>>addSpikyHair
| hair |
hair _ PolygonMorph
vertices: {83@3. 81@30. 91@27. 111@23.
97@32. 112@37. 99@45. 114@52. ... }

Anyone who wants to simplify the parser by eliminating {...} could simplify
it still further by eliminating #(...) as well. After all, #(...) can be
eliminated just like {...}.

It has always seemed a shame that there was no way to get a Point into a
literal array. It could be done: where is allowed, allow
@. That would be a special case, but the whole of #(...)
is a special case.

I agree that {...} is useful.

{e1. ... . en} is equivalent to
(OrderedCollection new "note no semicolon"
add: (e1);
...
add: (en);
asArray)
so it obviously CAN be eliminated. That doesn't mean it should be.
  1. @ can be eliminated too: aNumber @ anotherNumber is equivalent to
Point x: aNumber y: anotherNumber. That doesn't mean #@ should be
eliminated.

The practical questions are
- would eliminating this feature save more code in the parser and elsewhere
than it would cost in all the code using it (remember, not all such code
is known to SqC or anyone else)

- is ideological purity worth the loss of clarity?

- would it be feasible to make {} support a module?

At 8:49 +0200 9/30/01, ducasse stephane wrote:
>#() is necessary because it is compiled statically and cannot not be
>simulated by other construct. Storing #() in Stack frame is not really goo
>but this is an implementation aspect.

This is false. Any use of # can be eliminated by adding a class variable
and a class method using lazy initialisation. For example,
#( abc 'abc' 4 3.4 $r )

can be written as
MyClass literal27
where
MyClass class>>literal27
literal27 ifNil: [
literal27 := (OrderedCollection new
add: 'abc' asSymbol;
add: 'abc';
add: 4;
add: 3.4;
add: $r;
asArray)].
^literal27

Come to think of it, we could eliminate $r and 'abc' too:
'abc' is (String fromPacked: 6382179) allButFirst
$r is Character value: 114.

So
#(abc 'abc' 4 3.4 $r)
can, by reductio ad absurdum, be replaced by

MyClass class>>literal27
literal27 ifNil: [
literal27 := (OrderedCollection new
add: (String fromPacked: 6382179) allButFirst asSymbol;
add: (String fromPacked: 6382179) allButFirst;
add: 4;
add: 3.4;
add: (Character value: 114);
asArray)].
^literal27

without any non-numeric literals at all.

This is hardly less ridiculous than removing {}.