[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: macros / code construction (and assignment)



>>>>> "Rainer" == Rainer Blome <rainer@physik3.gwdg.de> writes:

    Dave> containers are an appealingly intuitive notion,
    Rainer> Sure, I want assignment to feel like that.

    Dave> and so I am happy to ground out where it does.
    Rainer> Only it doesn't ground out at containers, it grounds out
    Rainer> at the assignment primitive.

I suspect Dave may have been implying that he thinks of slots as
containers and that the way the assignment primitive works is meant to
suggest that.....


    Rainer> As Randy pointed out, (| x <- 7 |) means (| x = 7. x: arg
    Rainer> = <-. |).  This kind of syntactic sugar is indispensable.
    Rainer> That's what macros provide: syntactic sugar.

Something we talked about a lot in the course we ran at Brown last
spring was that for many of these tasks, Self's expressiveness is
sufficient.  (http://www.cs.brown.edu/courses/cs196b/)

    Rainer> Trying to explain what I do, I often explain to people why
    Rainer> Self doesn't need explicit control structures.  Then I get
    Rainer> to show the different syntax for `if'.  And most of them
    Rainer> instantly object to `bool if: then False: else'.
    Rainer> Everybody (including me) wants `if bool then else'.  So I
    Rainer> wouldn't call macros `efficiency hacks' (LPD), rather
    Rainer> `convenience hacks'.

You can get 90% of 'if bool then else':
if: bool Then: thenClause Else: elseClause = 
   ( bool if: thenClause False: elseClause ).

That's *my* point when explaining why Self doesn't need explicit
control structures.  You can define your own, with whatever order you
want.  The side benefit in my mind is that you *don't* need macros to
do it (a plus in my book) -- you just use message sends, something you
already need to know.  In Lisp or Scheme, you need to learn function
evaluation and then also learn macros.  Learning macros involves (as
Peter Deutsch points out) learning meta-levels of the language (and
even the concept of meta-levels (yes, we all studied grammar in
high-school, but how many people remember it and how many people
generalize the concept to arbitrary patterns of information?))

Part of this side benefit of not needing macros is that you can always
look at something and determine where the message send is.  Following
inheritance paths lets you find the definition of that message send.
When I compare this with the obfuscation possible with Lisp macros,
the obfuscation possible with Self seems better because it is easier
to figure out what the obfuscation is actually doing.


An aside on syntax:
What's the missing 10% in 'if bool then else'?  The fact that the
colons are there and the capitalization is a little funny.  You can
fix the capitalization with a minor tweak to Self's syntax -- simply
reverse which keywords need to be capitalized:

If: bool then: thenClause else:  elseClause =
   ( bool if: thenClause False: elseClause ).

leading to the following comparitively english-like usage:

If: someConditionIsTrue then: doSomething else: doSomethingElse.

Figure out some inference rule to get rid of the colons, then figure
out another one to allow white space in names and you're really
cooking.... 

If some condition is true then do something else do something else.



Brook