... continued... > > Of course it can. Here is one of your 5000 lines of mpz_add's: > > cpdef ModuleElement _iadd_(self, ModuleElement right): > # self and right are guaranteed to be Integers, self safe to > mutate > mpz_add(self.value, self.value, (<Integer>right).value) > return self
I would prefer the body of the program to be this: return (self= self+right) # mutate self to be the sum of self and right, computed by adding the values of self and right. In my generic package instead of sage: n._iadd_(5) I could do this.. (in-package :gmp ) ... (dsetv n (+ n 5) ) which is macroexpanded to (gmp_add (value n) (value n) (value #{constant 5 converted to a gmp number at compile time})) (return n) ;; well, the n object would be the result. > > It allows the user to do an inplace add for mpz's, using the syntax > William gave. The in-place add in my code is done by (dsetv ....) instead of (setf.... ) which would be normal lisp. > > > > You get to write papers on this stuff! I should change fields. You can write papers on anything at all. Publishing them in some stuffy conference is another matter :) > > > > > > Look, I agree that it would be a nice language feature. Even the C++ > preprocessor doesn't have enough macro expansion for my liking, and C+ > + is one of the languages used in Sage. This is definitely a nice > feature in Lisp. But it isn't going to be much of a draw card given > the other decisively off putting features of Lisp like difficult to > use packages and modules and the lack of a decent compiler and the > fact that there is very little community around it. Well, I don't know about there being no "decent compiler"; Sage has not chosen Lisps based on technical merit, and may have encountered ones without decent compilers. > > It would be a much more productive use of time to implement macros in > Python. Of course that is being done. There's a Google summer of code > project for it. I wonder what it is about mathematicians that makes them think it is a good idea to depend on high school students for production code. > > > > > If this kind of thing is not possible with Python, that is, in my > > view, unfortunate. > > Well, macros in the sense that you mean it are not. The other stuff > is, along with a hell of a lot that lisp can't easily do, due to the > overwhelming number of freely available modules you can just download > for python. Ah, I think I agree with you on the freely available modules in Python. The surprising thing is that many? all? of those Python modules can be downloaded into Lisp, too. In fact, I first tried loading gmp into lisp by loading gmpy. It worked, but I found it limiting. > <snipping out citations> > Does your citation rate go up when you post links to your papers all > over newsgroups by the way? I don't know. I don't count. > > Anyhow, thanks for the link, but I'm not presently interested in Lisp > or other language design features. You are welcome. I'm generally trying to add some light into the Sage discussion; it only descends to snarkiness because I am inclined to sarcasm and don't manage to edit it all out. RJF I'll store it in my memory banks > and come back to it later if I have a need for it. > > Bill. --~--~---------~--~----~------------~-------~--~----~ To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---