RE: Accessing Case Class - Subclasses

26 views
Skip to first unread message

Haoyi Li

unread,
Oct 28, 2013, 8:09:55 PM10/28/13
to jkl...@gmail.com, mac...@googlegroups.com
Nil = List.Nil

That's it =)

No way of doing it automatically, bit you can always reflection to look for subclasses and assign to __module__

Sent from my Windows Phone

From: jkl...@gmail.com
Sent: 10/28/2013 4:33 PM
To: mac...@googlegroups.com
Subject: Accessing Case Class - Subclasses

Is there a way to access a case class' subclass directly, without the using the parent name?

For instance, using the Cons List in your example, is there a way to make it so I can just type n = Nil() instead of n = List.Nil()?

Thanks!

--
You received this message because you are subscribed to the Google Groups "macropy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to macropy+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

jkl...@gmail.com

unread,
Oct 29, 2013, 11:54:53 PM10/29/13
to mac...@googlegroups.com, jkl...@gmail.com
Yeah kinda what I figured.  I think I can handle it from here.  Another quick question though, is there something wrong with the experimental macros? The majority of the tests seems to be commented out of the suite runner and I cannot get the examples for pattern matching to work. I get a "TypeError: switch() takes exactly 3 arguments (1 given)". Am I missing something?

Thanks!

Haoyi Li

unread,
Oct 30, 2013, 12:17:06 AM10/30/13
to jkl...@gmail.com, mac...@googlegroups.com
The tests are commented out because they're experimental =) partly I didn't want to run them every time (it takes a while) partly is that I didn't feel they were useful enough to bother keeping up to date while macropy was changing. I'd very much like to, but some of them I'm not sure are useful (e.g. pattern matching) and some of them would require more work than I'm willing to put in in order to bring them up to where I'd be happy (e.g. PINQ) so for now they're commented out and left there more as "this could be cool" examples rather than "this works!".
Reply all
Reply to author
Forward
0 new messages