On Sat, May 04, 2024 at 06:43:42AM +0200, Grégory Vanuxem wrote: > Hello, > > I have found 'devaluate' in some Spad files and it can be handy. <snip> > But, this is not my question, sometimes using 'devaluate' breaks > completely the code after, it's still compilable but not executable. > Any ideas why? > R is a Ring. > ===== spad =============== > NRing :String := string CAR((devaluate(R)$Lisp))$Lisp > > Rep := SExpression > pprint := true > > getind(m) ==> concat(["getindex(", "refs,_"", jlId m, "_")"]) > ===== > And later, the above macro is incorrectly treated (jlId is defined in > a category, and call the JLREFID *method*): > > >> System error: > There is no applicable method for the generic function > #<STANDARD-GENERIC-FUNCTION BOOT::JLREFID (1)> > when called with arguments > (|NemoIntegerMod|). > See also: > The ANSI Standard, Section 7.6.6 > > > A work around is: > ================================================ > NRing := CAR((devaluate(R)$Lisp))$Lisp pretend String > --NRing :String := string CAR((devaluate(R)$Lisp))$Lisp
Robust use is op_of_PS : Symbol := CAR(devaluate(PS)$Lisp)$Lisp Usage like in 'fmtjfricas.spad': n: String := string CAR(devaluate(f)$Lisp)$Lisp is error prone: essentially Spad compiler can call _any_ function 'string' which returns a String. Namely, '$Lisp' disables normal Spad typechecking and Spad compiler belives you that type is right one. Without further restictions (like 'string$Symbl') Spad will assume that call is OK. But the Lisp expression returns Lisp symbol, so return value of Symbol is fine. 'pretend String' is wrong, Lisp symbol is _not_ a string. Lisp symbol can be treated as SExpression, but 'string' in SExpression requires Lisp string so will fail on Lisp symbols. One you messed types 'sbcl' is free to generate wrong code. 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 view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/ZjY64A3C5CtsmZJD%40fricas.org.