Loading ...
Sorry, an error occurred while loading the content.

[self-interest] Self Syntax Question

Expand Messages
  • Stefan Matthias Aust
    Hi! I wonder whether the following describes correct Self syntax or not. I also wonder whether one would like to use it or not. First, some definitions: This
    Message 1 of 18 , Oct 5, 1999
    • 0 Attachment
      Hi!

      I wonder whether the following describes correct Self syntax or not. I
      also wonder whether one would like to use it or not. First, some definitions:

      This shall be a method definition

      (|
      foo = (bar).
      |)

      This shall be a constant definition, where "bar" is evaluated in the
      context of the "lobby" object.

      (|
      foo = bar.
      |)

      Obviously, when looking at the message "foo", you cannot distinguish
      whether it's a method call or a constant slot access.

      My question is, does this work only for unary message selectors or also for
      binary and keyword selectors? Or in other words, are these legal expressions?

      (|
      = whatever = false.
      ifTrue: aBlock = nil.
      |)

      My current SELF implementation requires a method object here, but
      especially for blocks etc., constant keyword slots would be handy, I think.


      bye
      --
      Stefan Matthias Aust // Bevor wir fallen, fallen wir lieber auf.
    • Jecel Assumpcao Jr
      ... Looking at the grammar definition for Self in the Programmer s Reference Manual it would seem that you should be able to place a regular object in
      Message 2 of 18 , Oct 5, 1999
      • 0 Attachment
        Stefan Matthias Aust wrote:
        > My question is, does this work only for unary message selectors or also for
        > binary and keyword selectors? Or in other words, are these legal expressions?
        >
        > (|
        > = whatever = false.
        > ifTrue: aBlock = nil.
        > |)

        Looking at the grammar definition for Self in the "Programmer's
        Reference Manual" it would seem that you should be able to place
        a "regular object" in there. That would be a literal object,
        optionally with code (which excludes things like false and nil).

        (| = x = false |) gives you a "Syntax Error: object expected"
        as the manual implied. Trying (| = x = (| a = 3 |) |) should
        have worked, but instead yielded "Syntax Error: empty objects
        cannot have arguments", which is a pretty obscure message for
        this error. Looking at the C++ code for the VM we can see that
        only method objects are allowed here, so it would be better if
        the message said so.

        > My current SELF implementation requires a method object here, but
        > especially for blocks etc., constant keyword slots would be handy, I think.

        I agree it would be interesting. When I wrote tinySelf 0, the grammar
        that I derived from the Self docs insisted on a method (I think it
        was based on Self 2.0) for binary and keyword slots and I had never
        thought about this.

        -- Jecel
      • David Ungar
        Great question! It should work, but I don t think it does in Self 4.0. - Dave ... David Ungar Sun Microsystems Laboratories (650) 336-2618
        Message 3 of 18 , Oct 5, 1999
        • 0 Attachment
          Great question!
          It should work, but I don't think it does in Self 4.0.

          - Dave


          At 10:18 PM +0200 10/5/99, Stefan Matthias Aust wrote:
          >Hi!
          >
          >I wonder whether the following describes correct Self syntax or not. I
          >also wonder whether one would like to use it or not. First, some definitions:
          >
          >This shall be a method definition
          >
          >(|
          >foo = (bar).
          > |)
          >
          >This shall be a constant definition, where "bar" is evaluated in the
          >context of the "lobby" object.
          >
          >(|
          >foo = bar.
          > |)
          >
          >Obviously, when looking at the message "foo", you cannot distinguish
          >whether it's a method call or a constant slot access.
          >
          >My question is, does this work only for unary message selectors or also for
          >binary and keyword selectors? Or in other words, are these legal expressions?
          >
          >(|
          >= whatever = false.
          >ifTrue: aBlock = nil.
          > |)
          >
          >My current SELF implementation requires a method object here, but
          >especially for blocks etc., constant keyword slots would be handy, I think.
          >
          >
          >bye
          >--
          >Stefan Matthias Aust // Bevor wir fallen, fallen wir lieber auf.
          >
          >------------------------------------------------------------------------
          >
          >eGroups.com home: http://www.egroups.com/group/self-interest
          >http://www.egroups.com - Simplifying group communications



          David Ungar
          Sun Microsystems Laboratories
          (650) 336-2618
        Your message has been successfully submitted and would be delivered to recipients shortly.