[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compiling.



=>    I compiled some files (in fact, some modules) written in Le_Lisp.  The
=> result is quite satisfying, but I noticed some strange behaviour I mention
=> hereafter.
=> 
=>    Let us consider the following button specification:
=> 
=> 	({butobj}:create 0
=> 	                 0
=> 	                 ({title}:create "Help")
=> 	                 (lambda (button)
=> 	                   (:display_help_menu ({link}:find button 'ctedit))))
=> 
=>    It is not equivalent to:
=> 
=> 	({butobj}:create 0
=> 	                 0
=> 	                 ({title}:create "Help")
=> 	                 #'(lambda (button)
=> 	                     (:display_help_menu ({link}:find button
=>                                                               'ctedit))))
=> 
=>    which signals an error.

#' is a macro equivalent to (function ...)
I have never used this fsubr. As far as I know, its use is not necessary in
the given example.
Maybe Ilog can tell you why it does not work under Complice.

=> 
=>    Second problem.  If you define a menu as a variable:
=> 
=> 	(defvar :tools_menu
=> 	  (let ((button_1 ...)
=> 	        ...
=> 	        (button_n ...))
=> 	    ({pulldown}:create 0 0 'column "My-tools" button_1 ... button_n)))
=> 
=>    an error message concerning the display is put down.  The right solution
=> seems to be:
=> 
=> 	(de :tools_menu ()
=> 	  (let ((button_1 ...)
=> 	        ...
=> 	        (button_n ...))
=> 	    ({pulldown}:create 0 0 'column "My-tools" button_1 ... button_n)))
=> 

There should not be code to be executed out of functions. It is always better
to write an initialize procedure for each module. For example it lets you load
a module which creates graphical objects before the display is open (before
you save your core), then initialize it once everything is OK.  There is an
automatic initialize procedure in Centaur. Look at the initializemodule
function in the "Centaur tools" manual.

=>    These two problems are surprising since they concern features that work fine
=> in interpreted mode.  Moreover, the second problem forces us to rewrite all the
=> uses of each menu!

A module which works in compiled mode still works in interpreted mode, that's
the most important point. I also regret that Complice is poorly documented,
and source code for it is not currently available.

=> 
=> 
=>    If the Le_Lisp environment used for compiling is "centaur", that is:
=> 
=> 	ROOTDIR=...
=> 	USERDIR=...
=> 	MODNAME=...
=> 	CMPLC=centaur
=> 
=> 	all: allcmplc
=> 
=> 	allcmplc:
=> 		$(ROOTDIR)bin/mkcmplc $(ROOTDIR) $(USERDIR) $(CMPLC) $(MODNAME)
=> 
=>    the following message is displayed:
=> 
=> 	adduservent: Permission denied.
=> 

There is a bug in the mkcmplc script file.
A work around is to replace centaur by 'centaur -top' (do not forget the
quotes).
This bug is now registered and will be fixed.

=> 
=>    Concerning a Le_Lisp problem, I think you know the function "quomod", such
=> that "(quomod n1 n2)" returns the quotient of "n1" by "n2" and stores the
=> remainder of this division in the global variable "#:ex:mod".  We could believe
=> that this global variable is known by the compiler.  Nay!  We have to declare
=> explicitly:
=> 
=> 	(defvar #:ex:mod)

Complice considers that a variable is global when its plist contains the
#:complice:globalvar tag.

You can see in module.lm files that there is a definition for each variable
declared in the module

(#:complice:declareglobalvar 'foo)

Suppose you compile a module. You can use extern global variables provided
that either they belong to an imported module or their plist contains the
#:complice:globalvar tag.

In the case of #:ex:mod, the genarith module, which defines the variable, is
not imported by the compiled module.
#:ex:mod is declared in the compiling environment, but its plist does not
contain the #:complice:globalvar tag. I think that the reason is that the
genarith module was loaded using a low level function, not loadmodule.

The good practice is to import genarith in the module.LM file.


Vincent Prunet