Menu

#14 SExpression atoms cause getOperator to fail

1.1.0
closed-fixed
algebra (9)
5
2008-01-16
2007-12-13
thechao
No

SExpression atoms cause getOperator to fail within the Syntax domain, however, there is no corresponding `atom?' function within Syntax. I'd suggest adding:

atom?: Syntax -> Boolean

It is not possible to check for this condition without forcing a conversion to SExpression.

Discussion

  • Gabriel Dos Reis

    Logged In: YES
    user_id=1496011
    Originator: NO

    Syntax is trying hard not to be SExpression.

    What really constitutes an `atom' depends on the usage (semantics) of
    the client of Syntax domain. So, it is trying to encourage more typed
    and semantics-based manipulation of syntax trees.

     
  • Gabriel Dos Reis

    • assigned_to: nobody --> dos-reis
     
  • thechao

    thechao - 2007-12-13

    Logged In: YES
    user_id=1312732
    Originator: YES

    Except that a call to "getOperator S" when "S" is an atom in a SExpression leads to a runtime error. There appears to be no way to detect the existence of an atom from a Syntax without converting the Syntax to an SEx and guarding against it being an atom.

     
  • Gabriel Dos Reis

    Logged In: YES
    user_id=1496011
    Originator: NO

    One does not call getOperator unconditionally -- just like one does not access
    a Union member unconditionally. If you think of Syntax as an `advanced' union,
    then you see that you have to test whether you have the right elements:

    The functions
    _case: (%, [|Integer|]) -> Boolean
    ++ x case Integer is true is x really is an Integer

    _case: (%, [|DoubleFloat|]) -> Boolean
    ++ x case DoubleFloat is true is x really is a DoubleFloat

    _case: (%, [|Symbol|]) -> Boolean
    ++ x case Symbol is true is x really is a Symbol

    _case: (%, [|String|]) -> Boolean
    ++ x case String is true is x really is a String

    nils?: % Boolean

    are precisely there to support type-based manipulation and query.

     
  • Gabriel Dos Reis

    • status: open --> closed-fixed
     

Log in to post a comment.