Lutz,
Actualy this should not occeur but its posisble, newlisp has some function
names "not much, luckely" that overlap 100% the C function names..
An example is "getenv" which occeurs in libc but also in libncurses, so
if you want to import it the "protection" error pops up... This all is not a problem
though to make newlisp functions unique an option could be to place an "-"
in between i.e. get-env to make it more newlispy...?
Well it not a big issue actualy because if you know its predefined in newlisp...
Norman.
The only thing which can we do in the moemnt is to define a wrapper function/DLL, when we want to import a function which exists as a newLISP command. The wrapper would translate a new name to the existing one.
No problem at all, you still can import getenv inside a context:
(context 'MYLIB)
(import "/usr/lib/libc.so.6" "getenv")
(context 'MAIN)
(get-string (MYLIB:getenv "PATH")) => "/bin:/usr/bin:/usr/local/bin ........
Lutz
if you insist on having it in the MAIN context you can read "hacking_newlisp.html" in the distribution doc directory and do:
(cpymem (pack "c c" 0 32) (last (dump 'getenv)) 2)
This will reset the protection bit on the symbol and still leave it global (see newlisp.h for the type flags)
Lutz
Thats a dymanic part of newlisp i like Lutz ;-)
Ill give it a try..always good to play with the internals..
Norman.
when you play with 'cpymem' make sure your are aware of the byte-order of your machine, the example was for Intel CPUs; on Mac OSX or Solaris you would have to do:
(cpymem (pack "c c" 32 0) (last (dump 'getenv)) 2)
reversing the bytes to high->low order
Lutz