On Thursday, June 01, 2006 2:59 AM Gernot Hueber wrote: > > > ... > > > Now, my questions: > > > .) s there a recommended/better way to call external functions > > > within Aldor/Axiom? > > > .) I think, the "defentry" part could be added with an Aldor > > > "Foreign Lisp" call? > > > .) How can I "load", external libraries (e.g. nputs.o)? > > > > > > > See: > > > > http://wiki.axiom-developer.org/SandBoxAldorForeign > > > > The first section containing > > > > (defentry |myprintf| (string) (int "printf")) > > > > is compiled as a lisp function but notice that it becomes > > part of the BOOT package. > > Well, I don't get this point, but I have to admit, I have no > understanding of the BOOT package. >
"package" is a name space concept in common lisp. The package name becomes part of the full name of a symbol like this: BOOT::myprintf BOOT is the name space used by Axiom. When Aldor code is compiled in Axiom the symbols default to a different package, therefore you must use the full name to call myprint. In Aldor the : must be escaped by _ so it looks rather messy BOOT_:_:myprintf Of course there might be other ways to accomplish this. Maybe someone more knowledgeable about lisp could help? > > > > For loading an external library did you try the usual Axiom > > command > > > > )library nputs.o > > > > Or via lisp like this: > > > > )lisp (load nputs.o) > > > > ? > > Sorry, no success: )lib nputs.o gives me ")library cannot > find the file nputs.", )lisp (load nputs.o) returns > "<< System error: The variable NPUTS is unbound". That's my confusion. I think what you need is (compiler::link ...) but that is beyond my level of competitence with GCL. Lisp users please help! > > I am thinking of importing defentry into Aldor to define the > C command to Lisp. Something like > ------------- > import {defentry: (??) -> ?} from Foreign Lisp; > > -- call imported defentry to declare C command to underlying Lisp > defentry("printf","string","int"); > ------------- > Obviously the give syntax wont work. But you could move the Lisp > defentry into Aldor. > I think you are right that Aldor should probably generate the defentry but foreign language interface is still not that standard in lisp, so what Aldor does might not be too portable. Since the current versiono of open source Axiom uses gcl, the foreign call mechanism would have to be compatible with this. > > > > > Can you send me the example code for 'nputs.c'? > > See for the full example: http://www.aldor.org/docs/HTML/chap19.html > ---- > /* > * nputs.c: A simple C function. > */ > void > nputs(int n, char *s) > { > int i; > for (i = 0; i < n; i++) puts(s); > } > ----- > Although I still cannot call this routine as an external library routine, I was able to compile and call it from inside Axiom. See my extended example at: http://wiki.axiom-developer.org/SandBoxAldorForeign Regards, Bill Page. _______________________________________________ Axiom-developer mailing list Axiom-developer@nongnu.org http://lists.nongnu.org/mailman/listinfo/axiom-developer