newLISP Fan Club

Forum => newLISP newS => Topic started by: starseed on August 17, 2006, 08:37:23 AM

Title: [bug] lambda? scanning error ...
Post by: starseed on August 17, 2006, 08:37:23 AM
Hi Lutz,



I have defined the following func:


(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:


> (load "tools.lsp")

invalid lambda expression : [text]lambda
      (list? val) 'list
      (macro? val) 'macro
      (string? val) 'string
      (symbol? val) 'symbol
      (atom? val) 'atom))
Title:
Post by: m i c h a e l on August 17, 2006, 01:27:48 PM
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
Title:
Post by: Lutz on August 17, 2006, 02:04:59 PM
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
(lambda)

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


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


Lutz



See also:

 http://newlisp.org/newlisp_manual.html#lambda_expressions
Title:
Post by: m i c h a e l on August 17, 2006, 09:02:16 PM
*embarrassed* I guess this Lutz guy knows something about this subject, so I will defer to him ;-)



m i c h a e l
Title:
Post by: starseed on August 18, 2006, 12:02:08 AM
Ahh, thank you.