Alasdair McAndrew wrote: > > Orright... two questions about > https://github.com/billpage/gsla/blob/master/gsl.spad, and in particular > the final three lines: > > gslIntegrationQng(f,a,b) == > r:List DF:=INTEGRATION_-QNG_-LIST(mkLispFunction1(f@(DF->DF))$Lisp,a,b)$Lisp > [r(1),r(2),r(3) pretend Integer] > > First the use of "pretend". As I understand it, "pretend" is a sort of > syntactic fudge factor to allow Axiom to compile code in which the types > may not be precisely fixed, or in which there may be a type mismatch. But > why is it needed particularly here - in the definition of > gslIntegrationQng? Surely an object is either an integer or it isn't, I > would have thought, and we can define the final value "neval" to be an > integer.
Expanding on Bill's answer: this code is an abuse (wrong). The core thing is that FriCAS list are homogeneous: all elements have the same type. In Lisp lists are allowed to have elements of different Lisp types. The integration routine returns two machine float and one machine integer. On Lisp side Bill packs this into a list. But on Spad side this List in an illegal object, so Bill lies and tells Spad compiler that the list contains DoubleFloat-s. Then he has to use 'pretend' to tell Spad compiler that the third element is in fact an integer. Currently this works, but will break down if Spad compiler becomes only slightly smarter: claiming that something is both DoubleFloat and Integer is a contradiction and may lead to wrong code or compile time error. > Second, the underscores in "INTEGRATION_-QNG_-LIST". Are these just to > escape the hyphens, lest SPAD confuse them with minus signs? After all, the > relevant function is defined in gsl.lisp as > > defun integration-qng-list (f a b) > (multiple-value-list (integration-qng f a b))) > > which incidentally would appear to indicate that one of the languages here > is case-insensitive. Or is there another reason? Underscores are just to escape hyphens. Note that hyphens in "INTEGRATION-QNG-LIST" are a self-inflicted hardship. On lisp side one can write: (defun INTEGRATION_QNG_LIST (f a b) ....) and on FriCAS side use the same "INTEGRATION_QNG_LIST". This is because FriCAS treat underscores which are not needed as escapes as literal underscores. Concerning case-sensitivity, Lisp have schizophrenia here: Lisp symbols are internally case sensitive, but by default on input Lisp will uppercase them. My personal style is to write symbols which are used from Spad in uppercase, so that Spad version and Lisp version looks the same. > > With regard to plain text format, I fully agree, and I'll do that if people > want. On the other hand, it's nice to have some way of distinguishing code > samples from text - the use of markdown is good for this, but I don't know > if google groups supports it. (Well, it sort of does, but through a > browser extension called "Markdown Here" which also supports LaTeX.) FYI, for me non-text part is junk that I delete without looking at. Using plain text save me work on deleting it. -- Waldek Hebisch -- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at http://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.