Movatterモバイル変換
[0]ホーム
If you want X, you know where to find it (was Re: do...until wisdom needed...)
Douglas Alannessus at mit.edu
Wed Apr 18 23:28:19 EDT 2001
"Andrew Dalke" <dalke at acm.org> writes:> Douglas Alan wrote:> > It's a very modern language (more modern in some ways than Python,> > multimethods and a sophisticated meta-object protocol being examples> > of two very modern features that it supports),> Yet more things I don't know about.Don't worry -- there's plenty of time to learn about this stuff. It'snot going anywhere. It's very interesting, though, if you are alanguage wonk.> *Sigh*. OTOH, if you want to know about details of structural> biology data structures and use cases .. I'm there!What's "structural biology"? One of my oldest friends has justfinished writing one of the first textbooks on computational biology.> Someone else pointed out to me in private mail a converter from> Fortran to Lisp. I think would prefer doing that by calling a> function with a string parameter and getting back, say, a module> object with the right function interfaces and constants defined.I'm not sure that this sort of thing should be held up as the posterchild for what you can do with macros, since I'm not sure I can see agood reason why you would want to translate Fortan to Lisp in a macro.If you did it the way that you propose, however, the translation wouldhappen at runtime, which would slow down your program. If it was doneas a macro, it would happen at compile time, which would not slow downyour program.Also, using your scheme, the Fortran code would not have access to anyLisp variables or data. With Fortran, I'm not too worried about this,but a good use for a macro mechanism might be because it would helpyou to embed some very specialized structural biology notation in withyour Lisp code, and it would be convenient if your notation and thestandard Lisp notation interoperate with each other smoothly and cansee each other's variables, etc. It's hard to do this with justprocedures and strings. (Is there a way in Python of finding localvariables by name on the Python stack so that a procedure can get andset variables in the caller's environment? If so, you could do it,but it would be pretty ugly.)> > More modestly, you> >might define two macros, "let" and "set" so that> > let x = 3>> This would at present raise a SyntaxError exception. I suppose> beforehand there would be a statement to make "let" be known> as a new keyword?Something like that. In Lisp this is not a problem since Lisp has nokeywords. Just how to do it in Python is not obvious and it wouldrequire some deep thought. You might have to settle instead forsomething like @let x = 3where "@" means that a macro invocation is coming up.> How do linters and other code checking utilities work on this sort> of mutability?They might operate on the code after it has been macro-expanded. Thenthe linters never see the macro invocations.> After all, they don't right now do a good job> parsing escaped ()s inside of regexps, which is another example of a> little language embedded inside of a bigger (and different) one.I'm not sure what problem you are refering to here. Is it just thatthey don't count the parens correctly? It sounds like these programsjust need better parsers.|>oug
More information about the Python-listmailing list
[8]ページ先頭