Re: [myhdl-list] Conversion of class methods
Brought to you by:
jandecaluwe
From: Oscar D. D. <osc...@gm...> - 2012-03-20 17:38:32
|
El Sat, 17 Mar 2012 09:34:21 -0500 Christopher Felton <chr...@gm...> escribió: > <snip> > > > > Performing a quick test by searching for "self" in the argument > > > list and ignoring the self argument will render the object method > > > convertible. > > > Adding these changes to > > > _AnalyzeTopFuncVisitor.vist_FunctionDev(...) (_analyze.py) > > > allows a top-level class method and buried methods to be > > > converted. I have prototyped and created some tests which can be > > > viewed here, > > > https://bitbucket.org/cfelton/myhdl-0.8-dev-containers/overview > > > (clone of the myhdl 0.8 dev, see notes at the end). > > > > Coming back to the important part of your message, you are right > > that calling the first method argument "self" is just a convention, > > not a requirement. Nevertheless I've never seen any python code > > that does not call the first method argument "self". Thus I don't > > think you should worry too much about it. I think that it would be > > safe to make that a requirement for MyHDL if you do not find a > > better way to differentiate between funcions and class methods. Note that, although the name can be anything, it always be the first unnamed argument. Checking the _AnalyzeTopFuncVisitor (conversion/analyze.py) function, it can extract all the argument list on strings, and assign them to all the signal objects, So, we should check if the list of strings and the list of signals have equal length. Otherwise, the first argument is a "self" object, and should be ignored on the list of strings (check "argnames" and "self.args" inside the function). I know it looks like a "ugly hack", when I get a better understanding of ast I check this again. > > > > As for your other questions, I find it a bit weird that the "signal > > containers" MEP refers to "classes" as well. I don't think that > > classes are normally considered containers even if strictly speaking > > they are. Perhaps it is because they are so much more than that... > > So my 0.02$ is that that part should be rolled into the MEP 108. > > What united the classes and other containers, in my mind, is how a > Signal and numeric values embedded in a "container" is transformed. > You are correct, a class can be a super set but it is also > container. The MEP only covers the container part of the class, that > is Signals, constants, and variables (?) as class attributes. Well, I think we should support classes, in the end, list and signals are also classes, and I think we shouldn't restrict cases like defining a custom container class. I think the problem here is how to access its members (index or attributes), I mean in the implementation. However, following the idea of "baby steps", I agree on starting only with lists and dicts. Also, note that in this objects, the access to its members is done by indexing. > > > > > I also think that it is perhaps a good idea to go the "baby steps" > > route and make a first version that does not handle class > > attributes. I believe that any progress is good progress. Having > > this feature, even in a limited form, may already prove useful, and > > it may even give you hints on how to proceed further later on. > > > > Cheers, > > > > Angel > > Thanks for the comments, > Chris > In summary: I agree on both MEPs, let me study them carefully to make additional comments. Great work Chris! Thanks a lot. > > ------------------------------------------------------------------------------ > This SF email is sponsosred by: > Try Windows Azure free for 90 days Click Here > http://p.sf.net/sfu/sfd2d-msazure > _______________________________________________ > myhdl-list mailing list > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list -- Oscar Díaz Key Fingerprint = 904B 306C C3C2 7487 650B BFAC EDA2 B702 90E9 9964 gpg --keyserver subkeys.pgp.net --recv-keys 90E99964 I recommend using OpenDocument Format for daily use and exchange of documents. http://www.fsf.org/campaigns/opendocument |