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

Why must getSlot be invoked on self when used in a method?

Expand Messages
  • eebel_igman
    Hello I m quite confused about the following behaviour: Example: Io m := method(nil) == method( nil ) Io getSlotReturnsNil := method(getSlot( m )) ==
    Message 1 of 2 , Jul 23, 2012
    View Source
    • 0 Attachment
      Hello

      I'm quite confused about the following behaviour:

      Example:
      Io> m := method(nil)
      ==> method(
      nil
      )
      Io> getSlotReturnsNil := method(getSlot("m"))
      ==> method(
      getSlot("m")
      )
      Io> getSlotOnSelfReturnsM := method(self getSlot("m"))
      ==> method(
      self getSlot("m")
      )
      Io> getSlotReturnsNil
      ==> nil
      Io> getSlotOnSelfReturnsM
      ==> method(
      nil
      )

      Why does the invocation of getSlot("m") in getSlotReturnsNil return nil?
      Best regards, Eebel
    • Steve Dekorte
      ... Hi Eebel, Try: getSlotReturnsNil := method(self getSlot( m )) getSlot is overridden on the Locals object and IIRC, is limited to the Locals themselves.
      Message 2 of 2 , Jul 23, 2012
      View Source
      • 0 Attachment
        On 2012-07-23 Mon, at 03:57 PM, eebel_igman wrote:
        > Io> getSlotReturnsNil := method(getSlot("m"))
        > ==> method(
        > getSlot("m")
        > )

        Hi Eebel,

        Try:

        getSlotReturnsNil := method(self getSlot("m"))

        getSlot is overridden on the Locals object and IIRC, is limited to the Locals themselves. There was a good reason for this, but I don't recall at the moment what it was.

        Steve
      Your message has been successfully submitted and would be delivered to recipients shortly.