<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
There is a small piece missing from the history here that makes the
brace syntax make more sense. Up until Squeak 2.0, there was a
provision in Squeak to have a brace array as an lval in an assignment
as a form of multiple value return. For example:<br>
<br>
{a . b} := aPoint xyArray.<br>
<br>
where<br>
<br>
Point>>xyArray <br>
^{ x . y}<br>
<br>
Some people feel that this reads better than:<br>
<br>
aPoint xyBlock: [ :x :y | a := x. b:= y]<br>
<br>
This is (as Eliot will recognize) essentially a very cut down version
of tuples and destructuring bind as implemented in a number of
functional languages. Gilad Bracha (Eliot's boss) wrote on such things
on his blog at <a class="moz-txt-link-freetext" href="http://gbracha.blogspot.com/2007/02/tuples.html">http://gbracha.blogspot.com/2007/02/tuples.html</a> and that
post is worth reviewing. He unfortunately abuses the term "literal" in
the post, as the brace syntax is better describes as a constructor that
is evaluated at run time.<br>
<br>
Cheers,<br>
-- John<br>
<br>
<br>
Eliot Miranda wrote:
<blockquote
cite="mid:3ac5ce8a0803241845t61a26a7cw852b9c014b48f179@mail.gmail.com"
type="cite"><br>
<br>
<div class="gmail_quote">On Mon, Mar 24, 2008 at 6:18 PM, Andres
Valloud <<a moz-do-not-send="true"
href="mailto:andres.valloud@gmail.com">andres.valloud@gmail.com</a>>
wrote:<br>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Eliot,<br>
<br>
Re: the Bezier2Segment... if I remember correctly, the {} syntax
creates a literal at compile time. Is that so? Or is the array
created every time execution goes over {}?<br>
<br>
In the case of Bezier2Segment, what I think is at times missing from
consideration is what is usually done with such arrays... do: aBlock?
Because if so, it would be cheaper (and *sometimes* clearer) to do:<br>
<br>
Bezier2Segment>>ellipseSegmentsDo: aBlock<br>
<br>
aBlock<br>
value: seg1a;<br>
value: seg1b;<br>
value: seg2a;<br>
value: seg2b;<br>
value: seg3a;<br>
value: seg3b;<br>
value: seg4a;<br>
value: seg4b</blockquote>
<div><br>
Um, semicolons aren't what you mean. You want a
Closure>>value:value:value:value:value:value:value:value: method
(right?), and there isn't one. You have to use valueWithArguments:.
But there isn't even an ArrayedCollection
class>>with:with:with:with:with:with:with:with: method to
construct one with(*). So once again a brace construct is the most
convenient way to implement
Closure>>value:value:value:value:value:value:value:value:.<br>
<br>
(*) at least you can write ArrayedCollection
class>>with:with:with:with:with:with:with:with:. You can't write
Closure>>value:value:value:value:value:value:value:value:value:
directly because it would be a primitive and either an 8-arg primitive
may not be available or a varargs primitive may not accept more than 3
arguments. If you write it in terms of valueWithArguments: you still
need Array class>>with:with:with:with:with:with:with:with: to
construct the argument vector (or of course the convenient brace
construct).<br>
<br>
</div>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">One
could further wonder why are there so many of these seg* things
floating around...</blockquote>
<div><br>
Because sometimes things come in octets... <br>
</div>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
Just my opinion though,<br>
<font color="#888888">Andres.</font>
<div>
<div class="Wj3C7c"><br>
<br>
<br>
<div class="gmail_quote">On Mon, Mar 24, 2008 at 6:09 PM, Eliot
Miranda <<a moz-do-not-send="true"
href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>>
wrote:<br>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
<div class="gmail_quote">
<div>On Sat, Mar 22, 2008 at 1:44 PM, Andres Valloud <<a
moz-do-not-send="true" href="mailto:andres.valloud@gmail.com"
target="_blank">andres.valloud@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I think something that is being left unaddressed is whether using
literal arrays that allow code expressions (e.g.: the brace syntax in
Squeak) is a good practice or not. In my experience, I have not felt
the need for such things, but maybe I have not been exposed to
particular circumstances in which they become useful. Does anybody
have some slam dunk examples that can be shared so that we can evaluate
this better?</blockquote>
</div>
<div><br>
Just open any recent Squeak image and broseer senders of #braceArray,
e.g. the last line of<br>
Bezier2Segment>>makeEllipseSegments: aRectangle in Squeak V3.9
reads<br>
<br>
^{seg1a. seg1b. seg2a. seg2b. seg3a. seg3b. seg4a. seg4b}<br>
<br>
instead of<br>
^(Array with: seg1a with: seg1b with: seg2a with: seg2b),<br>
(Array with: seg3a with: seg3b with: seg4a with: seg4b)<br>
<br>
BTW, the first example tat comes up in my image contains:<br>
{'zip'.'sar'.'pr'. 'mcz'. '*'} includes: suffix<br>
which is better written as<br>
#('zip' 'sar' 'pr' 'mcz' '*') includes: suffix<br>
so one can argue that it can be confusing for some to have two
apparently similar constructs. But in my experience {} carries its
weight (and there's no doubt that #() does).<br>
<br>
</div>
<div>
<div>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<font color="#888888"><br>
Andres.<br>
<br>
</font>
<div class="gmail_quote">
<div>
<div>On Tue, Mar 18, 2008 at 9:57 AM, Eliot Miranda <<a
moz-do-not-send="true" href="mailto:eliot.miranda@gmail.com"
target="_blank">eliot.miranda@gmail.com</a>> wrote:<br>
</div>
</div>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<div>
<div>On Mon, Mar 17, 2008 at 2:11 PM, Craig Latta <<a
moz-do-not-send="true" href="mailto:craig@netjam.org" target="_blank">craig@netjam.org</a>>
wrote:<br>
</div>
<div class="gmail_quote">
<div>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
> Defining new language elements is hard. The worst that could
happen<br>
> to this project, is to have extremely long threads with no
conclusion<br>
> as on the Squeak list.<br>
<br>
Indeed, although for what it's worth there's no lingering debate<br>
there on this particular issue[1]. ;)<br>
<br>
<br>
-C<br>
<br>
[1]<br>
<br>
Namely, the short form of...<br>
<br>
Array with: #foo with: #bar<br>
<br>
is...<br>
<br>
#(foo bar)<br>
<br>
as in Smalltalk-80, and the short form of...<br>
<br>
Array with: #foo with: true<br>
<br>
is...<br>
<br>
{#foo. true}</blockquote>
</div>
<div><br>
Well, in Squeak 3.9 I get<br>
<br>
Welcome to the finale version of 3.9 of 7 of November 2006<br>
#(nil true false foo) collect: [:ea| ea class] {UndefinedObject . True
. False . ByteSymbol}<br>
#(nil true false foo) printString '#(nil true false #foo)'<br>
<br>
</div>
<div>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
But I suspect the appropriate standard use of curly brackets<br>
across multiple dialects is a whole other morass. :)</blockquote>
</div>
<div><br>
Having been living with Squeak for a while now I really, really like
the curly brace syntax. I also note that it doesn't conflict with e.g.
VisualWorks use of #{name} for binding references. So I have a strong
personal preference for it, but that's just personal.<br>
<br>
</div>
</div>
<br>
<br>
</div>
</div>
<div>_______________________________________________<br>
ANSI-Smalltalk mailing list<br>
<a moz-do-not-send="true"
href="mailto:ANSI-Smalltalk@lists.openskills.org" target="_blank">ANSI-Smalltalk@lists.openskills.org</a><br>
<a moz-do-not-send="true"
href="http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk"
target="_blank">http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk</a><br>
<br>
</div>
</blockquote>
</div>
<br>
<br>
_______________________________________________<br>
ANSI-Smalltalk mailing list<br>
<a moz-do-not-send="true"
href="mailto:ANSI-Smalltalk@lists.openskills.org" target="_blank">ANSI-Smalltalk@lists.openskills.org</a><br>
<a moz-do-not-send="true"
href="http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk"
target="_blank">http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk</a><br>
<br>
</blockquote>
</div>
</div>
</div>
<br>
<br>
_______________________________________________<br>
ANSI-Smalltalk mailing list<br>
<a moz-do-not-send="true"
href="mailto:ANSI-Smalltalk@lists.openskills.org" target="_blank">ANSI-Smalltalk@lists.openskills.org</a><br>
<a moz-do-not-send="true"
href="http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk"
target="_blank">http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
<br>
_______________________________________________<br>
ANSI-Smalltalk mailing list<br>
<a moz-do-not-send="true"
href="mailto:ANSI-Smalltalk@lists.openskills.org">ANSI-Smalltalk@lists.openskills.org</a><br>
<a moz-do-not-send="true"
href="http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk"
target="_blank">http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk</a><br>
<br>
</blockquote>
</div>
<br>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
ANSI-Smalltalk mailing list
<a class="moz-txt-link-abbreviated" href="mailto:ANSI-Smalltalk@lists.openskills.org">ANSI-Smalltalk@lists.openskills.org</a>
<a class="moz-txt-link-freetext" href="http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk">http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
John Dougan
<a class="moz-txt-link-abbreviated" href="mailto:jdougan@acm.org">jdougan@acm.org</a></pre>
</body>
</html>