lihaoyi / macropy

Macros in Python: quasiquotes, case classes, LINQ and more!
3.28k stars 178 forks source link

Point example in readme does not work #69

Closed rebcabin closed 9 years ago

rebcabin commented 9 years ago

I made a Python file, mytest_case_classes.py, according to the documentation, namely

from macropy.case_classes import macros, case

@case
class Point(x, y): pass

p = Point(1, 2)
print str(p)

and get the following error in Python 2.7.10:

$ python mytest_case_classes.py 
Traceback (most recent call last):
  File "mytest_case_classes.py", line 4, in <module>
    class Point(x, y): pass
NameError: name 'x' is not defined

I get this consistently in the console and in ipython, as well. I inferred that I should be using Python 2 from the print statement; it would have been a print function call in Python 3, I believe.

rebcabin commented 9 years ago

I got some of the unit tests to work (see Issue #70), in particular, case_classes.py has a test that incorporates the example above and seems to run correctly. However, my example above still fails.

rebcabin commented 9 years ago

I learned that the example must be called from a second file that has

import macropy.activae
import import mytest_case_classes.py

I will attempt a clarification of the documents and submit a pull request