pyos / dg

A programming language for the CPython VM.
http://pyos.github.io/dg/
MIT License
577 stars 20 forks source link

Oddities of @ and compile errors #28

Open mationai opened 8 years ago

mationai commented 8 years ago
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.

pyos commented 8 years ago

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.