Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Native Calls

146 views
Skip to first unread message

david sletten

unread,
Dec 19, 2024, 4:17:24 AM12/19/24
to Shen
Hi everybody,

I am new to Shen and am having trouble with native calls. I installed kernel S39.1 on Ubuntu SBCL 2.4.10. I created a `sbcl-shen.exe` image which seems to work. However, according to the Wiki page I should be able to evaluate this:

(lisp.reverse [1 2 3 4 5])

But I get this error message:
(40-) (lisp.reverse [1 2 3 4 5])
fn: lisp.reverse is undefined

Am I missing something? Or has this behavior changed?

Have all good days!
David Sletten

dr.mt...@gmail.com

unread,
Dec 19, 2024, 4:33:54 AM12/19/24
to Shen
(0-) (reverse [1 2 3 4])
[4 3 2 1]

(1-) (REVERSE [1 2 3]) \\ Lisp native call in uppercase
[3 2 1]

(2-) ((fn reverse) [1 2 3 4]) \\ same as first case
[4 3 2 1]

(3-) ((fn REVERSE) [1 2 3 4])  \\ REVERSE is not defined in Shen
fn: REVERSE is undefined

(4-) (define r
       X -> (REVERSE X))  \\  trying to define it in Shen - no go
free variables in r: REVERSE

(5-) (define r  \\ getting it right
       X -> ((protect REVERSE) X))
(fn r)

(6-) (r [1 2 3])
[3 2 1]

(7-)  ((fn r) [1 2 3]) \\ r is defined in Shen
[3 2 1]

Mark

david sletten

unread,
Dec 19, 2024, 11:17:25 AM12/19/24
to Shen
Thanks for the insight. Hmm, I thought that I tried all caps...
This does not appear to be a general-purpose interface to the host language:
(65-) (TRUNCATE (/ 3 2))
1

(66-) (TRUNCATE 3 2)
The value
  3
is not of type
  (OR FUNCTION SYMBOL)

dr.mt...@gmail.com

unread,
Dec 19, 2024, 11:20:23 AM12/19/24
to Shen
((foreign TRUNCATE) 3 2)
1

In the absence of any info - Shen curries which CL
does not support.  foreign will suspend this. wrt REVERSE
obviously this is not a problem.  

M.

david sletten

unread,
Dec 19, 2024, 11:37:11 AM12/19/24
to Shen
Fantastic. Thanks Mark. And Thanks for your work on Shen in general. I have many chapters in TBoS to get through now!

dr.mt...@gmail.com

unread,
Dec 20, 2024, 12:31:44 AM12/20/24
to Shen
You're welcome.

M.

Reply all
Reply to author
Forward
0 new messages