On Sat, Nov 18, 2023 at 12:15:11PM +0800, Qian Yun wrote: > > > On 11/18/23 11:03, Waldek Hebisch wrote: > > On Wed, Nov 15, 2023 at 06:00:26PM +0800, Qian Yun wrote: > > > This is a relatively large misc cleanup, so I'd like a review before > > > commit. > > > > Looks mostly good. But I have doubts about two changes to > > fricas-lisp.lisp. First, removing extern declaration of 'sock_get_float' > > looks dangerous. Namely, extern declarations are needed. > > We provide extern declarations for ECL in 'ecl-foreign-call', > > but we do not do this for GCL. Is GCL providing extern > > declarations? If not we need our own. Second, I do not > > The other externs were removed in commit 84fc10e4 in 2008, only this > one remains.
AFAICS commit removed externs that we do not use and kept only used ones. > From GCL documentation: > > In order for C code to be loaded in by load you should declare any > variables and functions to be static. If you will link them in at > build time, of course you are allowed to define new externals. > > So declarations are needed when you want to load the compiled file > in interpreter. Since we are linking the .o files, this is not a > problem. This really says nothing about 'extern' declarations on Lisp side. And times have changed: old C had "implict int" rule governing undeclared functions, but this rule for many years were considered obsolete and now is gone from C standard. More important, C compilers frequently are configured to reject code trying to use undeclared functions. So, let me reiterate: extern declarations are needed. Now they should be present for all calls. For calls returning 'double' even with old rules call would not work (we would silently get wrong code). I did not add declarations earlier, as this could be done by Lisp implementation. But ECL folks do not want to do this, so we add them on FriCAS side. It is likely that GCL also is not adding declarations and that we need to add them on our side. > > know why you want to move definition of 'sockSendString'? > > It is closely related to 'sock_send_string_len' and keeping > > them together looks clearer for me. > > It is enclosed in "foreign-defs", which is defined differently > for CMUCL and CLISP. So for consistency, I'd like to move > it out of "foreign-defs". 'sockSendString' can not work without 'sock_send_string_len', so effectively its definition is complete only when "foreign-defs" are done. And 'sockSendString' is clesely related to 'sock_send_string_len'. So IMO "foreign-defs" is red herring here, for consistency we should keep the two functions together. -- 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/ZVig3dsjDlff00F3%40fricas.org.