variable definition in include files not usable in class file

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

variable definition in include files not usable in class file

Damien Mattei
hello,
i try to use a variable defined in an include files and i got an error,
i have a scheme class that run well:
https://github.com/damien-mattei/Jkawa/blob/master/DBtoWebObserversKawa.scm
after debug i had macros to hide the debug info in the log files, si i wrote some macros
that depending on a flag (debug-mode) print or not some info on output that go to log files,

those macros are in a  in a file used also by others scheme implementations (debug.scm :
https://github.com/damien-mattei/LOGIKI/blob/master/lib/debug.scm 
)
that is included by the previous one (DBtoWebObserversKawa.scm)
by an instruction loke this (see DBtoWebObserversKawa.scm):
(include-relative  "../git/LOGIKI/lib/debug.scm") ;; for debug
it adds some macro like those:

;; debug with display-nl
(define-syntax debug-display-nl
  (syntax-rules ()
    ((_ msg) (begin
               (display "debug.scm : debug-display-nl : debug-mode = ") ;; this has been added for debugging the debug macros !!! (and should be removed later)
               (display debug-mode)
               (newline)
               (if debug-mode
                  (begin (display msg)
                         (newline)))))))

or this special one chich is a macro that take another macro in argument:
;; tired of rewriting debug macros starting from normal ones i wrote this one that encapsulate ANY one !!!
(define-syntax debug-only
  (syntax-rules ()

    ((_ fct-or-mac ...)
     (begin
       (display "debug.scm : debug-only : debug-mode = ") ;; this has been added for debugging the debug macros !!! (and should be removed later)
       (display debug-mode)
       (newline)
       (when debug-mode
             (fct-or-mac ...))))
   
    ((_ instruction)
     (begin
       (display "debug.scm : debug-only : debug-mode = ") ;; this has been added for debugging the debug macros !!! (and should be removed later)
       (display debug-mode)
       (newline)
       (when debug-mode
             (instruction))))))

this works well in another Scheme implementation named Bigloo as in this file (part also of the Sidonie web application):
https://github.com/damien-mattei/Jbigl/blob/master/BiglooCode.scm

i hoped it could work also in Kawa, but i can not find a way (place) to define the flag called debug-mode
i tried many places, debug-mode is set to #t in debug.scm and DBtoWebObserversKawa.scm but at run-time appears to be #!null
in the log files:
(this does not prevent the application to run well but it is now impossible to have debug info in the Kawa part of the application)


03-Oct-2017 14:46:16.824 INFO [http-nio-127.0.0.1-8080-exec-767]
org.apache.catalina.startup.HostConfig.deployWAR Déploiement de l'archive
/usr/local/apache-tomcat-8.0.27/webapps/Sidonie.war de l'application web
03-Oct-2017 14:46:17.840 INFO [http-nio-127.0.0.1-8080-exec-767]
org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned
for TLDs yet contained no TLDs. Enable debug logging for this logger for a
complete list of JARs that were scanned but no TLDs were found in them.
Skipping unneeded JARs during scanning can improve startup time and JSP
compilation time.
03-Oct-2017 14:46:17.882 INFO [http-nio-127.0.0.1-8080-exec-767]
org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer.addServletWithApplication
Registering the Jersey servlet application, named eu.oca.ApplicationConfig,
at the servlet mapping /jersey/*, with the Application class of the same
name.
Sidonie : ApplicationConfig : getClasses : alreadyRun = false
Sidonie : ApplicationConfig : initSidonie : registering Scheme
environment...
Sidonie : ApplicationConfig : initSidonie : Scheme environment registered.
Sidonie : ApplicationConfig : initSidonie : path =
/usr/local/apache-tomcat-8.0.27/logs
Sidonie : ApplicationConfig : Hostname = moita.oca.eu
Sidonie : ApplicationConfig : webapps_dir =
/usr/local/apache-tomcat-8.0.27/webapps
Sidonie : DBtoWebObserversKawa : *init* : (WebAppsDirParam
::java.lang.String)
Sidonie : DataBase : searchDriver : driver found
Sidonie : DBtoWebObserversKawa : work : eu.oca.DataBase:searchDriverStatic
PASSED
Sidonie : DataBase : connectStatic : Hostname = moita.oca.eu
Sidonie : DataBase : connectStatic : using localhost as computer name and
mattei as user for sidonie database
Sidonie : DataBase : connectStatic : connection established
Sidonie : DBtoWebObserversKawa : work : eu.oca.DataBase:connectStatic PASSED
Sidonie : DataBase : createStatementStatic : done
Sidonie : DBtoWebObserversKawa : work :
eu.oca.DataBase:createStatementStatic PASSED
Sidonie : DBtoWebObserversKawa : work : fetching
http://ad.usno.navy.mil/wds/Webtextfiles/wdsnewref.txt ... could take a few
seconds to GET file ...
Sidonie : DBtoWebObserversKawa : work : before java.lang.System:getProperty
Sidonie : DBtoWebObserversKawa : work : after fetching or reading file
Sidonie : DBtoWebObserversKawa : work : creating regex.
Sidonie : DBtoWebObserversKawa : work : running
map-nil-iter-optim-tail-calls-call....
Sidonie : DBtoWebObserversKawa : work :: debug-mode = #t
Sidonie : DBtoWebObserversKawa : work : after let* declarations.
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
Sidonie : DBtoWebObserversKawa : work : Voila la valeur SQL de la requète :
marequete = SELECT * FROM Obs ORDER BY Auteur
Sidonie : DataBase : executeQueryStatic(String,String) : query: SELECT *
FROM Obs ORDER BY Auteur | name : Observateurs
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-display-nl : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
debug.scm : debug-only : debug-mode = #!null
Sidonie : DBtoWebObserversKawa : work : total = 492
Sidonie : DBtoWebObserversKawa : work : debug = #f
Sidonie : DBtoWebObserversKawa : work : result : entering HTML footer
writing...
Sidonie : DBtoWebObserversKawa : write-HTML-file-str : writing file
/usr/local/apache-tomcat-8.0.27/webapps/Sidonie/ObserversCodes.html...
Sidonie : DBtoWebObserversKawa : write-HTML-file-str : file written.
Sidonie : DBtoWebObserversKawa : work : debug = #f
Sidonie : DBtoWebObserversKawa : work : fullPathFileName =
/usr/local/apache-tomcat-8.0.27/webapps/Sidonie/ObservateursCodes.html
Sidonie : DBtoWebObserversKawa : work : writing file...
Sidonie : DBtoWebObserversKawa : write-HTML-file : writing file
/usr/local/apache-tomcat-8.0.27/webapps/Sidonie/ObservateursCodes.html...
Sidonie : DBtoWebObserversKawa : write-HTML-file : file written.
Sidonie : DBtoWebObserversKawa : work : after write-HTML-file
Sidonie : DBtoWebObserversKawa : write-HTML-file-str : writing file
/usr/local/apache-tomcat-8.0.27/webapps/Sidonie/ObservateursCodesAlphab.html...
Sidonie : DBtoWebObserversKawa : write-HTML-file-str : file written.
Sidonie : DataBase : closeStatic : resultSetObservateurs closed.
Sidonie : DataBase : closeStatic : statement closed.
Sidonie : DataBase : closeStatic : connect closed.
Sidonie : DataBase : closeStatic : connection to database closed.
Sidonie : DBtoWebObserversKawa : work : eu.oca.DataBase:closeStatic PASSED
Sidonie : ApplicationConfig : getClasses : alreadyRun = true
03-Oct-2017 14:46:23.949 INFO [http-nio-127.0.0.1-8080-exec-767]
org.glassfish.jersey.server.ApplicationHandler.initialize Initiating Jersey
application, version Jersey: 2.5.1 2014-01-02 13:43:00...
03-Oct-2017 14:46:24.243 INFO [http-nio-127.0.0.1-8080-exec-767]
org.apache.catalina.startup.HostConfig.deployWAR Deployment of web
application archive /usr/local/apache-tomcat-8.0.27/webapps/Sidonie.war has
finished in 7 419 ms

Damien
Reply | Threaded
Open this post in threaded view
|

Re: variable definition in include files not usable in class file

Sudarshan S Chawathe
I did not get a chance to look at your code carefully but, based on a
very quick look, I suspect that it may be running afoul of
syntactic-hygiene rules.  In particular, I believe that the identifier
debug-mode used in the syntax-definitions of 'debug', etc., cannot refer
to the top-level debug-mode variable due to hygiene rules.

Regards,

-chaw

Reply | Threaded
Open this post in threaded view
|

Re: variable definition in include files not usable in class file

Damien Mattei-2
possible, but i can explain it works in Bigloo if this one does not respect
hygienic expansion, but Bigloo do it:
https://www-sop.inria.fr/indes/fp/Bigloo/doc/bigloo-25.html#Macro-expansion
if there were some hygienic caveit in my macro definitions , it would fail
with Bigloo Scheme too,
but it works as you can see in this ouput of logs, when running another
portion of the code that use exactly the same debug macros, debug-macro is
well defined (#t):

Sidonie : ResultatMesuresF : postHandler : identificateur :N° BD
BiglooCode.scm :: ResultatMesuresF ::  debug-mode = #t
BiglooCode.scm :: ResultatMesuresF ::  nombreobjets = 0
BiglooCode.scm :: ResultatMesuresF :: bstr_identificateur = N° BD
BiglooCode.scm :: ResultatMesuresF :: bstr_objet = 56.130
BiglooCode.scm :: ResultatMesuresF :: len_identificateur = 6
BiglooCode.scm :: ResultatMesuresF :: (string? bstr_identificateur) = #f
BiglooCode.scm :: ResultatMesuresF :: identificateur = N° BD
BiglooCode.scm :: ResultatMesuresF :: (string? identificateur) = #t
TEST N° BD
TEST N° BD
BiglooCode.scm :: ResultatMesuresF :: essai = TEST N° BD
BiglooCode.scm :: ResultatMesuresF :: identificateur = N° BD
BiglooCode.scm :: ResultatMesuresF :: (string? essai) = #t
BiglooCode.scm :: ResultatMesuresF :: (string=?  identificateur "" ) = #f

Sidonie : DataBase : searchDriver : driver found
Sidonie : DataBase : connectStatic : Hostname = moita.oca.eu
Sidonie : DataBase : connectStatic : using localhost as computer name and
mattei as user for sidonie database
Sidonie : DataBase : connectStatic : connection established
Sidonie : DataBase : createStatementStatic : done

debug.scm : debug-display-nl : debug-mode = #t
BiglooCode.scm :: ResultatMesuresF :: choixres =
Ref
debug.scm : debug-display-nl : debug-mode = #t
BiglooCode.scm :: ResultatMesuresF :: (cond : Ref
debug.scm : debug-display-nl : debug-mode = #t

Damien


On Tue, Oct 3, 2017 at 5:21 PM, Sudarshan S Chawathe <[hidden email]> wrote:

> I did not get a chance to look at your code carefully but, based on a
> very quick look, I suspect that it may be running afoul of
> syntactic-hygiene rules.  In particular, I believe that the identifier
> debug-mode used in the syntax-definitions of 'debug', etc., cannot refer
> to the top-level debug-mode variable due to hygiene rules.
>
> Regards,
>
> -chaw
>
>
Reply | Threaded
Open this post in threaded view
|

Re: variable definition in include files not usable in class file

Damien Mattei-2
i wanted to say 'can not explain' in my previous message

Regards,
damien

On Tue, Oct 3, 2017 at 5:33 PM, Damien Mattei <[hidden email]>
wrote:

> possible, but i can explain it works in Bigloo if this one does not
> respect hygienic expansion, but Bigloo do it:
> https://www-sop.inria.fr/indes/fp/Bigloo/doc/bigloo-25.
> html#Macro-expansion
> if there were some hygienic caveit in my macro definitions , it would fail
> with Bigloo Scheme too,
> but it works as you can see in this ouput of logs, when running another
> portion of the code that use exactly the same debug macros, debug-macro is
> well defined (#t):
>
> Sidonie : ResultatMesuresF : postHandler : identificateur :N° BD
> BiglooCode.scm :: ResultatMesuresF ::  debug-mode = #t
> BiglooCode.scm :: ResultatMesuresF ::  nombreobjets = 0
> BiglooCode.scm :: ResultatMesuresF :: bstr_identificateur = N° BD
> BiglooCode.scm :: ResultatMesuresF :: bstr_objet = 56.130
> BiglooCode.scm :: ResultatMesuresF :: len_identificateur = 6
> BiglooCode.scm :: ResultatMesuresF :: (string? bstr_identificateur) = #f
> BiglooCode.scm :: ResultatMesuresF :: identificateur = N° BD
> BiglooCode.scm :: ResultatMesuresF :: (string? identificateur) = #t
> TEST N° BD
> TEST N° BD
> BiglooCode.scm :: ResultatMesuresF :: essai = TEST N° BD
> BiglooCode.scm :: ResultatMesuresF :: identificateur = N° BD
> BiglooCode.scm :: ResultatMesuresF :: (string? essai) = #t
> BiglooCode.scm :: ResultatMesuresF :: (string=?  identificateur "" ) = #f
>
> Sidonie : DataBase : searchDriver : driver found
> Sidonie : DataBase : connectStatic : Hostname = moita.oca.eu
> Sidonie : DataBase : connectStatic : using localhost as computer name and
> mattei as user for sidonie database
> Sidonie : DataBase : connectStatic : connection established
> Sidonie : DataBase : createStatementStatic : done
>
> debug.scm : debug-display-nl : debug-mode = #t
> BiglooCode.scm :: ResultatMesuresF :: choixres =
> Ref
> debug.scm : debug-display-nl : debug-mode = #t
> BiglooCode.scm :: ResultatMesuresF :: (cond : Ref
> debug.scm : debug-display-nl : debug-mode = #t
>
> Damien
>
>
> On Tue, Oct 3, 2017 at 5:21 PM, Sudarshan S Chawathe <[hidden email]>
> wrote:
>
>> I did not get a chance to look at your code carefully but, based on a
>> very quick look, I suspect that it may be running afoul of
>> syntactic-hygiene rules.  In particular, I believe that the identifier
>> debug-mode used in the syntax-definitions of 'debug', etc., cannot refer
>> to the top-level debug-mode variable due to hygiene rules.
>>
>> Regards,
>>
>> -chaw
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: variable definition in include files not usable in class file

Per Bothner
In reply to this post by Damien Mattei
On 10/03/2017 06:41 AM, Damien MATTEI wrote:
> hello,
> i try to use a variable defined in an include files and i got an error,

I assume you've tried replacing the 'include-relative' by directly pasting
(with your text editor) the contents of debug.scm?  That is useful for confirming
whether the issue specifically has to do with include.

Is more than one thread involved?  I.e. could debug-mode or debug-mode-save
be accessed from more than one thread?

Because of the way debug-mode-reload is implemented, it is not possible
to "nest" calls to your debug procedures.  I.e. you can't debug an expression
that calls a procedure that in turns uses debug.

It would be better to make debug-mode a parameter object:
https://www.gnu.org/software/kawa/Parameter-objects.html
That handles nesting and multiple threads.

Alternatively, you debug-mode a "fluid" variable. (Paramaters and
fluid variable are similar except you have to ad an extra layer of parentheses to
"call" a parameter object.)
https://www.gnu.org/software/kawa/Eval-and-Environments.html#idm139913596422880

(define-variable debug-mode #t)

(define-syntax debug
   (syntax-rules ()
     
     ((_ instruction)
      (fluid-let ((debug-mode #t))
         instruction))
     ...))
--
        --Per Bothner
[hidden email]   http://per.bothner.com/
Reply | Threaded
Open this post in threaded view
|

Re: variable definition in include files not usable in class file

Damien Mattei

i find the problem, can not explain it really, but it is solved ,see below:
Le Tuesday 03 October 2017 18:12:56 Per Bothner, vous avez écrit :
> On 10/03/2017 06:41 AM, Damien MATTEI wrote:
> > hello,
> > i try to use a variable defined in an include files and i got an error,
>
> I assume you've tried replacing the 'include-relative' by directly pasting
> (with your text editor) the contents of debug.scm?  That is useful for confirming
> whether the issue specifically has to do with include.
no but after test it does not change
>
> Is more than one thread involved?  I.e. could debug-mode or debug-mode-save
> be accessed from more than one thread?
at this time of test only one, but as the tomcat server "threads" the requests i can not say
that in all case, for example with multiple request at same time it can be the same thing
>
> Because of the way debug-mode-reload is implemented, it is not possible
> to "nest" calls to your debug procedures.  I.e. you can't debug an expression
> that calls a procedure that in turns uses debug.
yes, i understant debug-mode-reload is not "re-antrant" (french) meaning re-enter? in english
but this function is not used in Kawa or Bigloo, it was written for Racket Scheme and used in another code
>
> It would be better to make debug-mode a parameter object:
> https://www.gnu.org/software/kawa/Parameter-objects.html
> That handles nesting and multiple threads.
have read but i admit, i do not understand; requires perheaps some expert java knowledge i have not
>
> Alternatively, you debug-mode a "fluid" variable. (Paramaters and
> fluid variable are similar except you have to ad an extra layer of parentheses to
> "call" a parameter object.)
> https://www.gnu.org/software/kawa/Eval-and-Environments.html#idm139913596422880
>
> (define-variable debug-mode #t)
i try this (define-variable) but it compiles but crashed the apps on the deployment on the server, possible i put it in a bad place (class definition see commented code updated)
>
> (define-syntax debug
>    (syntax-rules ()
>      
>      ((_ instruction)
>       (fluid-let ((debug-mode #t))
>          instruction))
>      ...))

so finally , it worked simply by commenting
;;(debug-mode #t) in the LET definition in the main program function (not the include file)
and still putting in the main function a  (set! debug-mode #f) or (set! debug-mode #t)

in conclusion , and this the strange thing i do not really understand, the (define debug-mode #t) in debug.scm is
usefull to avoid a not defined variable error but the value of debug-mode has no effect after in the main function of the class,
you have to set! it otherwise it is in Kawa set to #!null and in Bigloo it is set to #f !!! (even with (define debug-mode #t) in debug.scm but bigloo scheme compiler to jvm is old, only the C is up to date)

i try also to change the place of the include-relative (to try to make the definitions near the us of them):
-before the module definition it is impossible (DBtoWebObserversKawa.scm:26:1: too late to set module-name)
-in the class definition,between the class name definition and the main (work) method it then simply ignore the definitions:
DBtoWebObserversKawa.scm:283:6: warning - no declaration seen for debug-only
DBtoWebObserversKawa.scm:397:9: warning - no declaration seen for debug-display-nl
-in the main method (named work) i have a new warning:
/home/mattei/Dropbox/Jkawa/../git/LOGIKI/lib/debug.scm:77:18: static DBtoWebObserversKawa references non-static debug-mode
DBtoWebObserversKawa.scm:56:22: warning - simple class DBtoWebObserversKawa requiring lexical link (because of reference to debug-mode) - use define-class instead


it works now (i commited the version that works)
thank for your help,
Damien