ian.woollard at gmail.com
Wed Nov 30 20:56:36 UTC 2005
So far as I know the '--' is incorrect syntax. It seems to be a
mistake in the tutorial, due to a formatting error.
On 11/30/05, sanssecours <sanssecours at f-m.fm> wrote:
> --- In self-interest at yahoogroups.com, Jecel Assumpcao Jr <jecel at m...>
> > sanssecours wrote on Tue, 29 Nov 2005 19:33:02 -0000
> > > I have to write a little paper about self. I haven't programmed
> > > anything in Self or Smalltalk yet and only have a little experience in
> > > the mainstream programming languages out there (C,Java..). I think I
> > > already understand the "basics" of the Language. However there are
> > > some code samples on the Self-Homepage that I don't understand for
> > > example:
> > Could you give a little more information about where you found this
> > example? There are a few things that are a bit strange about it.
> > > (| x. y |
> > > x: 3.··y: 4.
> > > x squared + y squared)
> > >
> > > Ok as far as I know that sample shows an object with two slots that
> > > contain the objects x and y but what do the rest of the code mean. It
> > > seems like the code declares some method that returns x squared + y
> > > squared but whats the name of this method how can you use this method
> > > (in Java something like: Object.Method() - whats the corresponding
> > > code in Self). And what do the Points: "··" between x: 3 and y: 4
> > > mean. It woul be very nice if sombeody out ther could help me.
> > I should point out that the textual syntax became less important when
> > the graphical programming environment was introduced in Self 4.0 (1995)
> > though it is still very convenient for discussing code via email and
> > stuff like that.
> > Your guess is correct - the syntax for an object or method is
> > ( | slots | code )
> > where the "code" part is empty for regular objects (not the case above)
> > so they simply return themselves when accessed as a value in some slot.
> > Methods can have local slots like "x" and "y" in the example but they
> > also can have argument slots that don't make sense for regular objects.
> > On the other hand, having a method loose like that instead of defined in
> > some slot doesn't make any sense, as you also guessed.
> > The two dashes before the "y:" could be a valid binary selector so the
> > code could be interpreted as
> > set "x" to 3
> > send "--" to self with the result of setting "y" to 4 as its argument
> > return the sum of the squares of "x" and "y"
> > The second line seems *very* strange. If I had to guess I would say that
> > some text transformation(s) converted two tabs or similar formatting
> > whitespace into dashes.
> > -- Jecel
> Thanks for your quick response Jecel. It was very helful altough I
> have to admit that I really don't understand everything you wrote.
> Maybe the fault are my poor english-skills or maybe it is the rather
> complex syntax of self that's that is confusing me. Here is my short
> interpration of what you've written:
> "define a object with the two objects x and y."
> (| x. y |
> x: 3.··y: 4. "set the object x to 3, set y to 4"
> x squared + y squared) "return (x squared) + (y squared) "
> Could you please explain me why you have to send "--" to self ?
> Wouldn't this example without the "--" also work as expected and did i
> get this right: the method actually has no name ? How do you call the
> method ?
> The code for the sample was taken from the sun-website:
> Greetings (and thanks again :-)
> Yahoo! Groups Links
Identity cards, cameras on every corner, long term detention without
trial, electronic tapping and reading of email/phone calls, speed
cameras that increase the death rate, extradition for torture - It's
all double plus good, Big Brother Blair and Uncle Bush are my friend!
More information about the Self-interest