[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 2.97 MB, 620x412, 1414982987839.webm [View same] [iqdb] [saucenao] [google]
6852264 No.6852264 [Reply] [Original]

I keep reading that LISP is a statically scoped language and can, sometimes offer dynamic scoping as well. I have no idea how that would work in LISP.

Can anyone show me pseudo code or actual code that illustrates dynamic scoping in LISP?

>> No.6852267

>>6852264
you'll probably have better luck in >>>/g/

>> No.6853279

>>6852264
It's related to whether it's interpreted or compiled.

>> No.6854053

>>6852264
I think you mean statically / dynamically typed, not scoped.

Here is an example of how its scope works (evaluates to true):

((λ (x)
(and ((λ (x)
(= x 1)) 1)
(= x 2))) 2)

The outer function has 2 bound to x, the inner has 1 bound to x.

>> No.6854069

You almost never want to use dynamic scoping. The only time I've done it was to patch in a sort of object-oriented virtual function-like thing into a program. I know it was wrong, and I've felt dirty ever since.

Here's a handy link that Google gave me.
http://n-a-n-o.com/lisp/cmucl-tutorials/LISP-tutorial-12.html