dg icon indicating copy to clipboard operation
dg copied to clipboard

Oddities of @ and compile errors

Open mationai opened this issue 9 years ago • 1 comments
trafficstars

Node = subclass object where
  __init__ = parent:None ~>
    @parent = parent
    @childs = []
    @i = 9
    None

  addChild = ~>
    node = Node @
    @i -= 1
    @childs.append node

Error:

    node = Node @
           ^
dg.SyntaxError: not something one can assign to

If the lines @i -= 1 and @childs.append node and swapped in order, then Error:

    node = Node @
NameError: name '@' is not defined

Problem 1: The ability of compiler telling me the real error is affected by seemingly unrelated code.

Problem 2: The other error 'not something one can assign to' is really confusing.

Problem 3: A @ by itself should stand for self as is in ruby, coffeescript, livescript, etc. self shouldn't even be defined since ~> is used and thus self isn't defined in the method parameter.

FYI, I really like the language, and find it fitting to me much more than other source to python compilers. I am raising the issues to hopefully make it even better or at least raise some awareness.

mationai avatar Sep 27 '16 07:09 mationai

Hm, it seems the parser consumes the next token after @ to form some weird construct where @ is called with the line break operator as an argument.

pyos avatar Sep 28 '16 18:09 pyos