On Tue, Apr 29, 2025 at 11:36:48AM +0200, 'Ralf Hemmecke' via FriCAS - computer algebra system wrote: > Hello Waldek, > > I just compiled this piece of code in a domain. > > modularGamma0?(x: %): Boolean == > for t in listOfTerms x repeat > if not modularGamma0?(t.k) then return false > true > > modularGamma1?(x: %): Boolean > for t in listOfTerms x repeat > if not modularGamma1?(t.k) then return false > true > > Obviously, I forgot to write "==" for the second function. > The compiler did not complain (which is of course inconvenient, since only > at the time when I wanted to use that function, FriCAS complained that > modularGamma1? was not implemented). > > Obviously, the "function body" for modularGamma1? becomes an argument of the > Boolean constructor and the whole expression is then just a declaration > without function body. > > However, I wonder, why the compiler considers this code as perfectly > acceptable. It should know that Boolean is a domain constructor without > arguments, right?
Compiler knows this when Boolean is declared. However, for bootstrap we need to deal with undeclared constructors. I think that even in normal use there are things which we can not check when they first appear, because needed info will be available only later. Also, we want incremental developement, which means that things could be redeclared. We probably could do more checking of types, but current compiler structure is based on using "unchecked" Lisp S-expression to represent signatures and it is problematic to add checks without introducing breakage. > That brings me to a curious next question. AFAIR, Aldor is able to create > two two domain constructors with different argument types but equal > identifier, i.e. Foo(X: Ring) and Foo(X: Group, Y: Ring) could be defined. > To my current knowledge that is not possible in SPAD, right? > Is this planned to be added? No concrete plans. IIUC Aldor allows overloading for constructors. But this adds a lot of complications to type checking I doubt if benefits of overloading justify needed effort. Variable number of arguments is a simple variant of overloading, which looks much easier to support. Still, benefits look limited. In general my main direction of changes to Spad compiler is correctness. For example, your recent testcase uncovered fact that condition checking mostly works for simple cases, but is badly broken for deeply nested types. There are cases when compiler does not look at the correct signature. -- 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 visit https://groups.google.com/d/msgid/fricas-devel/aBFDmXjAb25nnCXZ%40fricas.org.