[bug] lambda? scanning error ...

Notices and updates
Locked
starseed
Posts: 38
Joined: Thu Jul 27, 2006 8:45 pm

[bug] lambda? scanning error ...

Post 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))

m i c h a e l
Posts: 394
Joined: Wed Apr 26, 2006 3:37 am
Location: Oregon, USA
Contact:

Post 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

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post 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

m i c h a e l
Posts: 394
Joined: Wed Apr 26, 2006 3:37 am
Location: Oregon, USA
Contact:

Post 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

starseed
Posts: 38
Joined: Thu Jul 27, 2006 8:45 pm

Post by starseed »

Ahh, thank you.

Locked