Nп/п : 36 из 93
 От   : none) (albert                       2:5075/128        15 авг 23 10:40:54
 К    : Kaz Kylheku                                           15 авг 23 11:42:02
 Тема : Re: Closures
----------------------------------------------------------------------------------
                                                                                 
@MSGID:
d3ae72e3
@REPLY: <20230815002701.354@kylheku.com> 7dface35
@REPLYADDR none) (albert
@REPLYTO 2:5075/128 none) (albert
@CHRS: CP866 2
@RFC: 1 0
@RFC-References:
<2023Aug14.161756@mips.complang.tuwien.ac.at>
<20230815002701.354@kylheku.com>
@RFC-Message-ID:

@TZUTC: 0200
@TID: FIDOGATE-5.12-ge4e8b94
In article <20230815002701.354@kylheku.com>,
Kaz Kylheku  <864-117-4973@kylheku.com> wrote:
>On 2023-08-15, albert@cherry.(none) (albert)  wrote:
>> That would mean that
>>     (def! fib (fn* (N) (if (= N 0) 1
>>             (if (= N 1) 1 (+ (fib (- N 1))
>>             (fib (- N 2)))))))
>> would fail,  but it isn`t:
>> (fib 10)
>
>fib is not capturing lexical closures. There are multiple instances, but
>they are not accessible at the same time.  In particular, once any
>activation of fib terminates, nothing accesses that instance of N any
>more.

Obviously not, I observed that. The test for capturing lexical closures
fails, but fib is not.


>Lexical closures mean that the variables visible in any activation of a
>function can live indefinitely.  Lexical closures are objects that can
>escape from the context where they are created, and be invoked after
>that context has terminated.
This is lisp parlance. The concept of lexical closures is present
in algol 68, but the term is not used.
Any language that supports functions within functions, functions as
first order objects and persistance (items created in a function that
have a life span longer than the function call) has this feature.

>Mastodon: @Kazinator@mstdn.ca

Groetjes Albert
-- 
Don`t praise the day before the evening. One swallow doesn`t make spring.
You must not say "hey" before you have crossed the bridge. Don`t sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning.            - the Wise from Antrim -
--- trn 4.0-test77 (Sep 1, 2010)
 * Origin: KPN B.V. (2:5075/128)
SEEN-BY: 5001/100 5015/255 5019/40 5020/715 848
1042 4441 12000 5030/49 1081
SEEN-BY: 5058/104 5075/128
@PATH: 5075/128 5020/1042 4441



   GoldED+ VK   │                                                 │   09:55:30    
                                                                                
В этой области больше нет сообщений.

Остаться здесь
Перейти к списку сообщений
Перейти к списку эх