Page 1 of 1

[bug] lambda? scanning error ...

Posted: Thu Aug 17, 2006 3:37 pm
by starseed
Hi Lutz,

I have defined the following func:

Code: Select all

(define (type val)
   (if
      (float? val) 'float
      (integer? val) 'integer
      (lambda? val) 'lambda
      (list? val) 'list
      (macro? val) 'macro
      (string? val) 'string
      (symbol? val) 'symbol
      (atom? val) 'atom))
in a file called tools.lsp, now when I load this file, I get an error:

Code: Select all

> (load "tools.lsp")

invalid lambda expression : [text]lambda
      (list? val) 'list
      (macro? val) 'macro
      (string? val) 'string
      (symbol? val) 'symbol
      (atom? val) 'atom))

Posted: Thu Aug 17, 2006 8:27 pm
by m i c h a e l
Hi Ingo,

If you change the results from symbols into strings, you should get what you wanted. The symbols are conflicting with the names of the functions, which are symbols!

m i c h a e l

Posted: Thu Aug 17, 2006 9:04 pm
by Lutz
Using symbols is fine. It's the "lambda" (and "fn", "lambda-macro", "fn-macro") the only strings which are wired into the scanner and only accepted after an opening parenthesis to identify a lambda type expression or list. Use another word as a workaround. These words should not be used as symbols and are part of the newLISP syntax.

For example

Code: Select all

(lambda)
is not a list with one symbol lambda but an empty lambda list:

Code: Select all

(empty? (lambda)) => true
(length (lambda)) => 0
(first (lambda)) => nil
(lambda? (lambda)) => true
Lutz

See also:
http://newlisp.org/newlisp_manual.html# ... xpressions

Posted: Fri Aug 18, 2006 4:02 am
by m i c h a e l
*embarrassed* I guess this Lutz guy knows something about this subject, so I will defer to him ;-)

m i c h a e l

Posted: Fri Aug 18, 2006 7:02 am
by starseed
Ahh, thank you.