Comment warning when loading file with macro

8 views
Skip to first unread message

Paolo Amoroso

unread,
Apr 1, 2023, 8:30:34 AM4/1/23
to Medley Interlisp Users/Interest
The source file of my Stringscope program includes the following Interlisp macro:

(DEFMACRO WITH.INPUT.FILE ((STREAM FILE)
                           &BODY BODY &AUX (RESULT (GENSYM))
                           (VALUE (GENSYM)))

         (* Opens an input stream to FILE and evaluates the forms in BODY with the stream
         bound to STREAM. Returns the value of the last form in BODY, or NIL if FILE can
         not be opened.)

   `(PROG NIL
          [SETQ ,RESULT (NLSETQ (OPENSTREAM ,FILE 'INPUT]
          (if ,RESULT
              then (SETQ ,STREAM (CAR ,RESULT))
                   (SETQ ,VALUE (PROGN ,@BODY))
                   (CLOSEF ,STREAM)
                   (RETURN ,VALUE)
            else (RETURN NIL))))


When I LOAD or FILESLOAD the file I get this warning:

Warning: Possible comment not stripped (* Opens an input stream to FILE and evaluates the forms in BODY with the stream bound to STREAM. Returns the value of the last form in BODY, or NIL if FILE can not be opened.)

While I understand the compiler or loader may not be able to strip the comment from the compiled file or memory given its location in the source, I wonder where else I should move the comment in the code to prevent the warning. Outside of DEFMACRO? Can comments be inserted in a DEFMACRO form?


Paolo
--

Larry Masinter

unread,
Apr 3, 2023, 12:49:49 AM4/3/23
to Paolo Amoroso, Medley Interlisp Users/Interest
I'm not entirely sure why this warning happens at the time that it does. Probably some heuristic that the implementor was't sure of.
The only files that contains the string "possible comment" are in the source medley/sources/CMLDEFFER and in the documentation file  medley/docs/SEC3-IRMFEATURES-II.pdf (also in the medley repository) page 24

image.png
So you could set *REMOVE-INTERLISP-COMMENTS* to T and not get any warnings. (The warning was only useful when loading old code and most always ignorable).

Alternatively, you could 'convert' the comments to a newer Medley format -- In SEdit select the comment or the whole body of the definition and press alt-; (command ; on mac).

This form of comment takes the form (* ;; "a string") where the comment is represented in memory as a list of three elements, the symbol IL:*, a symbol in the IL package consisting of 1, 2 or 3 semicolons, and a string. Such forms are assumed to be intended as comments. This format is supported by SEdit so you usually will see the comment justified in 1 of 3 possible ways.

Because comments are stripped by the definer (the DEFFER in CMLDEFFER), you can put comments anywhere in code that is introduced by a definer. 

DEFMACRO isn't really an "Interlisp macro". If you ask (EQ 'CL:DEFMACRO 'IL:DEFMACRO) you will get T, and if you ?? EQ to look on the history it will show as (EQ 'DEFMACRO 'DEFMACRO) from either kind of exec. The name of the macro has a package, but that doesn't determine the interpretation.

I found the stash of TEdit files that constituted the Medley 1 release notes; Ill submit a PR adding them. 

Do we update the document, change the default warning?

--
https://Interlisp.org for more details
---
You received this message because you are subscribed to the Google Groups "Medley Interlisp Users/Interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to interlisp+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/interlisp/CAGi1hzuvvyzCMr2jCWpa7fCbhCx4Ui%3DYLPP-5nB%2B4Nc2OBgoPw%40mail.gmail.com.


--

Paolo Amoroso

unread,
Apr 3, 2023, 8:19:01 AM4/3/23
to Larry Masinter, Medley Interlisp Users/Interest
Thanks, I converted the comment and the warning went away.


Paolo
--

Larry Masinter

unread,
Apr 3, 2023, 12:14:51 PM4/3/23
to Paolo Amoroso, Medley Interlisp Users/Interest

--
https://Interlisp.org for more details
---
You received this message because you are subscribed to the Google Groups "Medley Interlisp Users/Interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to interlisp+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages