Ok_Specific_7749

joined 1 year ago
[–] [email protected] 1 points 1 year ago (1 children)

Why must the variable c be declared outside and before the function definition my-counter!.
[ If you put it inside the value is always "reset"]

 

A counter in racket-scheme:

#lang typed/racket

(define my-counter!
    (let ([t 0])
        (lambda ()
	        (set! t (+ 1 t))
	    t);lambda
	);let
);define 
(print (my-counter!))
(print (my-counter!))

A counter in sbcl-lisp:

load "~/quicklisp/setup.lisp")

(declaim (optimize (speed 3) (safety 3)))

(let ((c 0))
    (defun my-counter! ()
        (lambda ()
            (setf c (+ 1 c))
	    c); lambda
	 ) ;defun
) ;let

(defun main ()
(print (funcall (my-counter!)))
(print (funcall (my-counter!)))
)

(sb-ext:save-lisp-and-die "test.exe" :toplevel #'main :executable t)

Could someone elaborate why i need "funcall" in lisp and not in scheme ? And why the different placing of let ?

[–] [email protected] 1 points 1 year ago

After analyzing i will focus on racket & sbcl & haskell.
Why ? Many libraries & descend books.

[–] [email protected] 1 points 1 year ago (1 children)

My favorite scheme/lisp implementations are sbcl/racket/chicken.
Not because of speed or portability but mainly because of available libraries.

[–] [email protected] 1 points 1 year ago (1 children)

Stating the obvious.

 

What are the strengths , weaknesses.
How to compare sbcl with clojure