Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - lotabout

#1
Normally, functions string will wrap the contents with quotes, just like:

(string '(a b c))
=> "(a b c)"


but when the text becomes too long, then it will wrap it with [text][/text] markup instead of quotes("). Is there a way to keep using quotes?


(string (symbols))
=> "(...)"

instead of

(string (symbols))
=> [text]( ... )[/text]


PS: I'm trying to integrate slimv with newlisp, and has to send the text in the quoted format, but the behavior of `string' differs.
#2
Whither newLISP? / Howto Solve Context Collision
March 19, 2013, 09:45:17 PM
I am new to newLISP, and just can't find out how to solve this problem.



As we know, we can surround a macro to avoid variable capture.

But if we write two diffierent modules without knowing the other one, we might

encounter a context collision, i.e. useing the same name for context.



here is an example:



In module 'A', we define a macro 'my-set' and put it in context 'my-set'(just to illustrate).

; A.lsp
(context 'my-set)
(define-macro (my-set a b)
  (set (eval a) b))
(context MAIN)
(context 'A)
(define (my-test x)
  (letex (x x) (my-set:my-set 'y x)))
(context MAIN)


And now we write module 'B' without recognizing the existence of module 'A'.

; B.lsp
(context 'my-set)
(define-macro (my-set a b)
  (set  (eval b) a))
(context MAIN)
(context 'B)
(define (my-test x)
  (letex (x x) (my-set:my-set x 'y)))
(context MAIN)


Now we see that we have two implementations of 'my-set' macro in the same

context, if we load these two files at the same time, one will break the other.

if we load 'A.lsp' first, and then 'B.lsp', then the definition of 'my-set' in

B will overwrite that in 'A.lsp', so the 'my-test' function in 'A.lsp' will

fail.



Cause contexts can be seen globally instead of being shadowed by the other

contexts. And we might be using different modules written by different people,

and somehow they might have context collision, and I just wondering how to deal

with this situation.