Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

Frankly, Scarlett, I don't have a fix. -- Rhett Buggler


devel / comp.arch / Re: Nested functions and representation of closures

SubjectAuthor
* What the World Needs NowQuadibloc
+* Re: What the World Needs NowMitchAlsup
|+* Re: What the World Needs NowQuadibloc
||+- Re: What the World Needs NowScott Lurndal
||+* Re: What the World Needs NowMitchAlsup
|||`* Re: What the World Needs NowQuadibloc
||| `- Re: What the World Needs NowQuadibloc
||`- Re: What the World Needs NowQuadibloc
|`* Re: What the World Needs NowEricP
| +- Re: What the World Needs NowBGB
| `* Re: What the World Needs NowQuadibloc
|  +* Re: What the World Needs NowEricP
|  |`* Re: What the World Needs NowQuadibloc
|  | +* Re: What the World Needs NowMitchAlsup
|  | |`- Re: What the World Needs NowQuadibloc
|  | `* Re: What the World Needs NowEricP
|  |  +* Re: What the World Needs NowThomas Koenig
|  |  |+- Re: What the World Needs NowMitchAlsup
|  |  |`- Re: What the World Needs NowScott Lurndal
|  |  +- Re: What the World Needs NowQuadibloc
|  |  `* Re: What the World Needs NowBGB
|  |   `* Re: What the World Needs NowEricP
|  |    +- Re: What the World Needs NowBGB
|  |    `* Re: What the World Needs NowMitchAlsup
|  |     `* Re: What the World Needs NowEricP
|  |      +* Re: What the World Needs NowMitchAlsup
|  |      |`* Re: What the World Needs NowEricP
|  |      | `* Re: What the World Needs NowMitchAlsup
|  |      |  `- Re: What the World Needs NowScott Lurndal
|  |      `* Re: What the World Needs NowScott Lurndal
|  |       `- Re: What the World Needs NowMitchAlsup
|  `* Re: What the World Needs NowAnton Ertl
|   `* Re: What the World Needs NowQuadibloc
|    +* Re: What the World Needs NowQuadibloc
|    |+- Re: What the World Needs NowQuadibloc
|    |`- Re: What the World Needs NowAnton Ertl
|    +* Re: What the World Needs NowAnton Ertl
|    |+* Re: What the World Needs NowQuadibloc
|    ||`- Re: What the World Needs NowAnton Ertl
|    |`* Re: What the World Needs NowScott Lurndal
|    | `- Re: What the World Needs NowQuadibloc
|    `* Re: What the World Needs NowAnton Ertl
|     `* Re: What the World Needs NowThomas Koenig
|      +- Re: What the World Needs NowAnton Ertl
|      `* Re: Secrets of the ancients, What the World Needs NowJohn Levine
|       `* Re: Secrets of the ancients, What the World Needs NowThomas Koenig
|        `* Re: Secrets of the ancients, What the World Needs NowJohn Levine
|         `* Re: Secrets of the ancients, What the World Needs NowThomas Koenig
|          +* Re: Secrets of the ancients, What the World Needs NowJohn Levine
|          |`* Re: Secrets of the ancients, What the World Needs NowScott Lurndal
|          | `* Re: Secrets of the ancients, What the World Needs NowJohn Levine
|          |  `- Re: Secrets of the ancients, What the World Needs NowMitchAlsup
|          `* Re: Secrets of the ancients, What the World Needs NowNiklas Holsti
|           `* Re: Secrets of the ancients, What the World Needs NowAnton Ertl
|            `* Re: Secrets of the ancients, What the World Needs NowNiklas Holsti
|             +* Re: Secrets of the ancients, What the World Needs NowThomas Koenig
|             |+* Re: Secrets of the ancients, What the World Needs NowMitchAlsup
|             ||`* Re: Secrets of the ancients, What the World Needs NowNiklas Holsti
|             || +- Re: Secrets of the ancients, What the World Needs NowMitchAlsup
|             || `* Re: Secrets of the ancients, What the World Needs NowTerje Mathisen
|             ||  `- Re: Secrets of the ancients, What the World Needs NowNiklas Holsti
|             |`- Re: Secrets of the ancients, What the World Needs NowNiklas Holsti
|             +* Re: Secrets of the ancients, What the World Needs NowDavid Brown
|             |`* Re: Secrets of the ancients, What the World Needs NowStephen Fuld
|             | `* Re: Secrets of the ancients, What the World Needs NowAnton Ertl
|             |  +* Re: Secrets of the ancients, What the World Needs NowMitchAlsup
|             |  |+* Re: Secrets of the ancients, What the World Needs NowAnton Ertl
|             |  ||`* Nested functions and representation of closures (was: Secrets of the ancients, WStefan Monnier
|             |  || +* Re: Nested functions and representation of closuresDavid Brown
|             |  || |+* Re: Nested functions and representation of closuresThomas Koenig
|             |  || ||`* Re: Nested functions and representation of closuresEricP
|             |  || || `* Re: Nested functions and representation of closuresMitchAlsup
|             |  || ||  `- Re: Nested functions and representation of closuresEricP
|             |  || |`* Re: Nested functions and representation of closuresMichael S
|             |  || | `- Re: Nested functions and representation of closuresDavid Brown
|             |  || `* Re: Nested functions and representation of closures (was: Secrets of the ancientAnton Ertl
|             |  ||  `- Re: Nested functions and representation of closuresBGB
|             |  |+- Re: Secrets of the ancients, What the World Needs NowGeorge Neuner
|             |  |`- Re: Secrets of the ancients, What the World Needs NowJean-Marc Bourguet
|             |  `* Re: Secrets of the ancients, What the World Needs NowTim Rentsch
|             |   `* Re: Secrets of the ancients, What the World Needs NowMitchAlsup
|             |    +* Re: Secrets of the ancients, What the World Needs NowJohn Levine
|             |    |+- Re: Secrets of the ancients, What the World Needs NowMitchAlsup
|             |    |`* Re: Secrets of the ancients, What the World Needs NowAnton Ertl
|             |    | `- Re: Secrets of the ancients, What the World Needs NowGeorge Neuner
|             |    `- Re: Secrets of the ancients, What the World Needs NowTim Rentsch
|             `- Re: Secrets of the ancients, What the World Needs NowThomas Koenig
`* Re: What the World Needs NowQuadibloc
 `* Re: What the World Needs NowQuadibloc
  `- Re: What the World Needs NowQuadibloc

Pages:1234
Re: Secrets of the ancients, What the World Needs Now

<kuj2dnFe72iU1@mid.individual.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35955&group=comp.arch#35955

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news-2.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.holsti@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.arch
Subject: Re: Secrets of the ancients, What the World Needs Now
Date: Thu, 21 Dec 2023 17:03:19 +0200
Organization: Tidorum Ltd
Lines: 28
Message-ID: <kuj2dnFe72iU1@mid.individual.net>
References: <uletbu$19ohv$1@dont-email.me>
<ulml73$10fu3$1@newsreader4.netcologne.de> <uln60k$2m9s$1@gal.iecc.com>
<uln86f$10rpl$1@newsreader4.netcologne.de> <ulnj9g$2719$1@gal.iecc.com>
<uls9ri$144lp$1@newsreader4.netcologne.de> <kue2p4FbsrjU1@mid.individual.net>
<2023Dec19.191250@mips.complang.tuwien.ac.at>
<kuegl7FbsrjU2@mid.individual.net> <ult3ms$14n37$1@newsreader4.netcologne.de>
<dc73b645013a758c6bd9d18b0fcbfb22@news.novabbs.com>
<kufo8dFmig3U1@mid.individual.net> <um1b33$12lv4$2@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net OvzzDsjDbSiiSRUiqL2hrwTR26QcwWMGNEz+pnGm7ZmrbsVqYj
Cancel-Lock: sha1:zDek/ac1Y1Bw+jZdUey0SxZYOI8= sha256:B5hKd3mDmXXbf0/P0U13n9u1b57V9qpBzdCHlvMiFCY=
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <um1b33$12lv4$2@dont-email.me>
 by: Niklas Holsti - Thu, 21 Dec 2023 15:03 UTC

On 2023-12-21 14:29, Terje Mathisen wrote:
> Niklas Holsti wrote:

[snip]

>> Ada compilers are required to evaluate typeless constant arithmetic to
>> unbounded precision (as "bignums"). For example, the constant pi is
>> defined thusly in the standard package Ada.Numerics:
>>
>>      Pi : constant :=
>>         3.14159_26535_89793_23846_26433_83279_50288_41971_69399_37511;
>>
>> and all the digits are significant in any computation involving Pi and
>> other typeless constants.

[snip]

> And still, 50 digits is only ~170 bits, so not enough to do arbitrary
> parameter reductions (which requires ~1100 bits).

Ada compilers are explicitly allowed to define Ada.Numerics.Pi with more
digits if they want to do so (which sort of introduces a portability
problem, oops...)

I believe they are also allowed to use a more precise approximation of
pi in the numerical library functions.

Re: Nested functions and representation of closures

<vJZgN.93193$Wp_8.19994@fx17.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35959&group=comp.arch#35959

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!news.swapon.de!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx17.iad.POSTED!not-for-mail
From: ThatWouldBeTelling@thevillage.com (EricP)
User-Agent: Thunderbird 2.0.0.24 (Windows/20100228)
MIME-Version: 1.0
Newsgroups: comp.arch
Subject: Re: Nested functions and representation of closures
References: <uletbu$19ohv$1@dont-email.me> <ulml73$10fu3$1@newsreader4.netcologne.de> <uln60k$2m9s$1@gal.iecc.com> <uln86f$10rpl$1@newsreader4.netcologne.de> <ulnj9g$2719$1@gal.iecc.com> <uls9ri$144lp$1@newsreader4.netcologne.de> <kue2p4FbsrjU1@mid.individual.net> <2023Dec19.191250@mips.complang.tuwien.ac.at> <kuegl7FbsrjU2@mid.individual.net> <ulusjs$j0q5$3@dont-email.me> <ulvac2$l7hl$1@dont-email.me> <2023Dec20.194712@mips.complang.tuwien.ac.at> <4bab9ad8e39f0b0c1610a7549478c9ac@news.novabbs.com> <2023Dec20.223744@mips.complang.tuwien.ac.at> <jwva5q4bjqs.fsf-monnier+comp.arch@gnu.org> <ulvr5s$o52i$1@dont-email.me> <um1d1k$17d9u$1@newsreader4.netcologne.de>
In-Reply-To: <um1d1k$17d9u$1@newsreader4.netcologne.de>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 71
Message-ID: <vJZgN.93193$Wp_8.19994@fx17.iad>
X-Complaints-To: abuse@UsenetServer.com
NNTP-Posting-Date: Thu, 21 Dec 2023 16:29:15 UTC
Date: Thu, 21 Dec 2023 11:28:47 -0500
X-Received-Bytes: 3550
 by: EricP - Thu, 21 Dec 2023 16:28 UTC

Thomas Koenig wrote:
> David Brown <david.brown@hesbynett.no> schrieb:
>
>> So what saves C is that nested functions are not part of the language!
>> And when you have extensions that support nested functions, such as
>> supported by gcc, if the function really needs a fat pointer you have a
>> trampoline on the stack to hide that and make it look like a normal
>> "thin" pointer.
>
> I looked at what the Fortran compilers I could lay my hands on did
> with the following code, which uses a contained subroutine inside
> a subroutine:
>
> module test
> contains
> subroutine t(f)
> interface
> subroutine f()
> end subroutine
> end interface
> call f()
> end subroutine
> end module
>
> subroutine foo(i)
> use test
> integer, intent(inout):: i
> call t(bar)
> contains
> subroutine bar()
> call xxx(i)
> end
> end
>
> Interestingly, every compiler I could lay my hands on on short
> notice (gfortran for several architectures, ifort, xlf, the new
> flang for llvm) used trampolines.
>
> See https://godbolt.org/z/nv5nr934q , which is for POWER and
> contains a call to a subroutine suggestively called
> __trampoline_setup.

BTW this requires a RWE stack.
The x64 gfortran is considerably simpler.
It stuffs two MOV reg,imm and a CALL instructions on the stack at RSP+8,
copies RSP+8 to RDI, calls test_MOD which jumps to RDI.

bar.0:
mov rdi, QWORD PTR [r10]
jmp xxx_
__test_MOD_t:
jmp rdi
foo_:
sub rsp, 56
mov edx, -17599 // REX MOV reg,imm
mov ecx, -17847 // REX MOV reg,imm
mov QWORD PTR [rsp], rdi
lea rdi, [rsp+8]
mov WORD PTR [rsp+8], dx
mov edx, OFFSET FLAT:bar.0
mov QWORD PTR [rsp+40], 0
mov DWORD PTR [rsp+10], edx
mov WORD PTR [rsp+14], cx
mov QWORD PTR [rsp+16], rsp
mov DWORD PTR [rsp+24], -1864106167 // REX CALL
call __test_MOD_t
add rsp, 56
ret

Re: Nested functions and representation of closures

<c69c0d57000440fe8a391d55c8974716@news.novabbs.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35964&group=comp.arch#35964

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!.POSTED!not-for-mail
From: mitchalsup@aol.com (MitchAlsup)
Newsgroups: comp.arch
Subject: Re: Nested functions and representation of closures
Date: Thu, 21 Dec 2023 18:20:20 +0000
Organization: novaBBS
Message-ID: <c69c0d57000440fe8a391d55c8974716@news.novabbs.com>
References: <uletbu$19ohv$1@dont-email.me> <ulml73$10fu3$1@newsreader4.netcologne.de> <uln60k$2m9s$1@gal.iecc.com> <uln86f$10rpl$1@newsreader4.netcologne.de> <ulnj9g$2719$1@gal.iecc.com> <uls9ri$144lp$1@newsreader4.netcologne.de> <kue2p4FbsrjU1@mid.individual.net> <2023Dec19.191250@mips.complang.tuwien.ac.at> <kuegl7FbsrjU2@mid.individual.net> <ulusjs$j0q5$3@dont-email.me> <ulvac2$l7hl$1@dont-email.me> <2023Dec20.194712@mips.complang.tuwien.ac.at> <4bab9ad8e39f0b0c1610a7549478c9ac@news.novabbs.com> <2023Dec20.223744@mips.complang.tuwien.ac.at> <jwva5q4bjqs.fsf-monnier+comp.arch@gnu.org> <ulvr5s$o52i$1@dont-email.me> <um1d1k$17d9u$1@newsreader4.netcologne.de> <vJZgN.93193$Wp_8.19994@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="677458"; mail-complaints-to="usenet@i2pn2.org";
posting-account="t+lO0yBNO1zGxasPvGSZV1BRu71QKx+JE37DnW+83jQ";
User-Agent: Rocksolid Light
X-Rslight-Site: $2y$10$1Q/oN./uBdx16csnpl92WOeOUYG4hINdNVzEHN9K7cFWGo9ns6TRi
X-Rslight-Posting-User: 7e9c45bcd6d4757c5904fbe9a694742e6f8aa949
X-Spam-Checker-Version: SpamAssassin 4.0.0
 by: MitchAlsup - Thu, 21 Dec 2023 18:20 UTC

EricP wrote:

> Thomas Koenig wrote:
>> David Brown <david.brown@hesbynett.no> schrieb:
>>
>>> So what saves C is that nested functions are not part of the language!
>>> And when you have extensions that support nested functions, such as
>>> supported by gcc, if the function really needs a fat pointer you have a
>>> trampoline on the stack to hide that and make it look like a normal
>>> "thin" pointer.
>>
>> I looked at what the Fortran compilers I could lay my hands on did
>> with the following code, which uses a contained subroutine inside
>> a subroutine:
>>
>> module test
>> contains
>> subroutine t(f)
>> interface
>> subroutine f()
>> end subroutine
>> end interface
>> call f()
>> end subroutine
>> end module
>>
>> subroutine foo(i)
>> use test
>> integer, intent(inout):: i
>> call t(bar)
>> contains
>> subroutine bar()
>> call xxx(i)
>> end
>> end
>>
>> Interestingly, every compiler I could lay my hands on on short
>> notice (gfortran for several architectures, ifort, xlf, the new
>> flang for llvm) used trampolines.
>>
>> See https://godbolt.org/z/nv5nr934q , which is for POWER and
>> contains a call to a subroutine suggestively called
>> __trampoline_setup.

> BTW this requires a RWE stack.
> The x64 gfortran is considerably simpler.
> It stuffs two MOV reg,imm and a CALL instructions on the stack at RSP+8,
> copies RSP+8 to RDI, calls test_MOD which jumps to RDI.

> bar.0:
> mov rdi, QWORD PTR [r10]

Where is R10 made to point at i ??

> jmp xxx_
> __test_MOD_t:
> jmp rdi
> foo_:
> sub rsp, 56
> mov edx, -17599 // REX MOV reg,imm
> mov ecx, -17847 // REX MOV reg,imm
> mov QWORD PTR [rsp], rdi
> lea rdi, [rsp+8]
> mov WORD PTR [rsp+8], dx
> mov edx, OFFSET FLAT:bar.0
> mov QWORD PTR [rsp+40], 0
> mov DWORD PTR [rsp+10], edx
> mov WORD PTR [rsp+14], cx
> mov QWORD PTR [rsp+16], rsp
> mov DWORD PTR [rsp+24], -1864106167 // REX CALL
> call __test_MOD_t
> add rsp, 56
> ret

Re: Nested functions and representation of closures

<9p0hN.83955$p%Mb.50230@fx15.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35968&group=comp.arch#35968

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx15.iad.POSTED!not-for-mail
From: ThatWouldBeTelling@thevillage.com (EricP)
User-Agent: Thunderbird 2.0.0.24 (Windows/20100228)
MIME-Version: 1.0
Newsgroups: comp.arch
Subject: Re: Nested functions and representation of closures
References: <uletbu$19ohv$1@dont-email.me> <ulml73$10fu3$1@newsreader4.netcologne.de> <uln60k$2m9s$1@gal.iecc.com> <uln86f$10rpl$1@newsreader4.netcologne.de> <ulnj9g$2719$1@gal.iecc.com> <uls9ri$144lp$1@newsreader4.netcologne.de> <kue2p4FbsrjU1@mid.individual.net> <2023Dec19.191250@mips.complang.tuwien.ac.at> <kuegl7FbsrjU2@mid.individual.net> <ulusjs$j0q5$3@dont-email.me> <ulvac2$l7hl$1@dont-email.me> <2023Dec20.194712@mips.complang.tuwien.ac.at> <4bab9ad8e39f0b0c1610a7549478c9ac@news.novabbs.com> <2023Dec20.223744@mips.complang.tuwien.ac.at> <jwva5q4bjqs.fsf-monnier+comp.arch@gnu.org> <ulvr5s$o52i$1@dont-email.me> <um1d1k$17d9u$1@newsreader4.netcologne.de> <vJZgN.93193$Wp_8.19994@fx17.iad> <c69c0d57000440fe8a391d55c8974716@news.novabbs.com>
In-Reply-To: <c69c0d57000440fe8a391d55c8974716@news.novabbs.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 85
Message-ID: <9p0hN.83955$p%Mb.50230@fx15.iad>
X-Complaints-To: abuse@UsenetServer.com
NNTP-Posting-Date: Thu, 21 Dec 2023 19:32:21 UTC
Date: Thu, 21 Dec 2023 14:31:34 -0500
X-Received-Bytes: 4174
 by: EricP - Thu, 21 Dec 2023 19:31 UTC

MitchAlsup wrote:
> EricP wrote:
>
>> Thomas Koenig wrote:
>>> David Brown <david.brown@hesbynett.no> schrieb:
>>>
>>>> So what saves C is that nested functions are not part of the
>>>> language! And when you have extensions that support nested
>>>> functions, such as supported by gcc, if the function really needs a
>>>> fat pointer you have a trampoline on the stack to hide that and make
>>>> it look like a normal "thin" pointer.
>>>
>>> I looked at what the Fortran compilers I could lay my hands on did
>>> with the following code, which uses a contained subroutine inside
>>> a subroutine:
>>>
>>> module test
>>> contains
>>> subroutine t(f)
>>> interface
>>> subroutine f()
>>> end subroutine
>>> end interface
>>> call f()
>>> end subroutine
>>> end module
>>>
>>> subroutine foo(i)
>>> use test
>>> integer, intent(inout):: i
>>> call t(bar)
>>> contains
>>> subroutine bar()
>>> call xxx(i)
>>> end end
>>>
>>> Interestingly, every compiler I could lay my hands on on short
>>> notice (gfortran for several architectures, ifort, xlf, the new
>>> flang for llvm) used trampolines.
>>>
>>> See https://godbolt.org/z/nv5nr934q , which is for POWER and
>>> contains a call to a subroutine suggestively called
>>> __trampoline_setup.
>
>> BTW this requires a RWE stack.
>> The x64 gfortran is considerably simpler.
>> It stuffs two MOV reg,imm and a CALL instructions on the stack at RSP+8,
>> copies RSP+8 to RDI, calls test_MOD which jumps to RDI.
>
>> bar.0:
>> mov rdi, QWORD PTR [r10]
>
> Where is R10 made to point at i ??
>
>> jmp xxx_
>> __test_MOD_t:
>> jmp rdi
>> foo_:
>> sub rsp, 56
>> mov edx, -17599 // REX MOV reg,imm
>> mov ecx, -17847 // REX MOV reg,imm
>> mov QWORD PTR [rsp], rdi
>> lea rdi, [rsp+8]
>> mov WORD PTR [rsp+8], dx
>> mov edx, OFFSET FLAT:bar.0
>> mov QWORD PTR [rsp+40], 0
>> mov DWORD PTR [rsp+10], edx
>> mov WORD PTR [rsp+14], cx
>> mov QWORD PTR [rsp+16], rsp
>> mov DWORD PTR [rsp+24], -1864106167 // REX CALL
>> call __test_MOD_t
>> add rsp, 56
>> ret

-17847 = BA4A = REX.WX MOV r10,imm64
mov QWORD PTR [rsp],rdi copies i in rdi to the bottom of stack [RSP].
mov WORD PTR [rsp+14],cx stuffs REX.WX MOV r10,imm64 onto stack
mov QWORD PTR [rsp+16],rsp copies RSP onto stack after REX.WX MOV, r10,imm64

At execution REX.WX MOV r10,imm64 loads prior rsp that points to i into r10
bar.0:
mov rdi, QWORD PTR [r10] loads i into rdi

Re: Secrets of the ancients, What the World Needs Now

<um4083$192uu$1@newsreader4.netcologne.de>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35977&group=comp.arch#35977

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-f912-0-f825-fef6-e99a-1095.ipv6dyn.netcologne.de!not-for-mail
From: tkoenig@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: Secrets of the ancients, What the World Needs Now
Date: Fri, 22 Dec 2023 12:42:43 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <um4083$192uu$1@newsreader4.netcologne.de>
References: <uletbu$19ohv$1@dont-email.me>
<ulml73$10fu3$1@newsreader4.netcologne.de> <uln60k$2m9s$1@gal.iecc.com>
<uln86f$10rpl$1@newsreader4.netcologne.de> <ulnj9g$2719$1@gal.iecc.com>
<uls9ri$144lp$1@newsreader4.netcologne.de>
<kue2p4FbsrjU1@mid.individual.net>
<2023Dec19.191250@mips.complang.tuwien.ac.at>
<kuegl7FbsrjU2@mid.individual.net>
Injection-Date: Fri, 22 Dec 2023 12:42:43 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-f912-0-f825-fef6-e99a-1095.ipv6dyn.netcologne.de:2001:4dd7:f912:0:f825:fef6:e99a:1095";
logging-data="1346526"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Fri, 22 Dec 2023 12:42 UTC

Niklas Holsti <niklas.holsti@tidorum.invalid> schrieb:
> On 2023-12-19 20:12, Anton Ertl wrote:
>> Niklas Holsti <niklas.holsti@tidorum.invalid> writes:
>>> In my own (non-critical) Ada programs, small nested subprograms are not
>>> unusual, but pointers to them are very rare (I don't recall a single
>>> case of it).
>>
>> That's interesting, because a major reason for using nested functions
>> (or, more generally, closures), is if you need to pass a function with
>> a given interface, but have to pass additional data to that function.
>
>
> In Ada, instead of passing a (nested) function pointer to some service
> that needs such a parameter, one can implement the service as a generic
> program unit, where the function to be passed is given as a generic
> parameter, and instantiate that generic locally in the nested context,
> thus binding the instance with the nested function.

It would be interesting to see how Ada compilers handle nested
functions. Would it be possible to create an Ada equivalent
of https://godbolt.org/z/e5cr9EoE3 (I hope the syntax is clear)
and post it?

Re: Secrets of the ancients, What the World Needs Now

<658b00c3$0$8221$426a74cc@news.free.fr>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=36375&group=comp.arch#36375

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!cleanfeed1-b.proxad.net!nnrp4-1.free.fr!not-for-mail
From: jm@bourguet.org (Jean-Marc Bourguet)
Newsgroups: comp.arch
Subject: Re: Secrets of the ancients, What the World Needs Now
References: <uletbu$19ohv$1@dont-email.me>
<ulml73$10fu3$1@newsreader4.netcologne.de>
<uln60k$2m9s$1@gal.iecc.com>
<uln86f$10rpl$1@newsreader4.netcologne.de>
<ulnj9g$2719$1@gal.iecc.com>
<uls9ri$144lp$1@newsreader4.netcologne.de>
<kue2p4FbsrjU1@mid.individual.net>
<2023Dec19.191250@mips.complang.tuwien.ac.at>
<kuegl7FbsrjU2@mid.individual.net> <ulusjs$j0q5$3@dont-email.me>
<ulvac2$l7hl$1@dont-email.me>
<2023Dec20.194712@mips.complang.tuwien.ac.at>
<4bab9ad8e39f0b0c1610a7549478c9ac@news.novabbs.com>
Date: Tue, 26 Dec 2023 17:35:14 +0100
Cancel-Lock: sha1:MT+JXvauUDzETk0FqBCajMg9fI4=
MIME-Version: 1.0
Content-Type: text/plain
Lines: 84
Message-ID: <658b00c3$0$8221$426a74cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 26 Dec 2023 17:35:16 CET
NNTP-Posting-Host: 145.224.92.109
X-Trace: 1703608516 news-1.free.fr 8221 145.224.92.109:2448
X-Complaints-To: abuse@proxad.net
 by: Jean-Marc Bourguet - Tue, 26 Dec 2023 16:35 UTC

mitchalsup@aol.com (MitchAlsup) writes:

> Anton Ertl wrote:
>
>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> writes:
>>> I believe Pascal, back in the 1970s implemented nested functions, though
>>> I don't know how any specific implementation accomplished it.
>
>> AFAIK Pascal implementations all just use static links chains to the
>> enclosing scopes. So you access an outer local by following the link
>> chain as many levels as you cross scopes.
>
> How does Pascal do this counting when there are recursive frames on the
> stack ??

There are two kind of frame links: the dynamic links point just to the frame of
the caller, the static link to the lexically enclosing frame.

Something like (in a C-like syntax with nested function):

void f() {
int fv;

void f1() {
use(fv);
}

void f2() {
int f2v;

void f2a(int r) {
if (r != 0) {
f2a(r-1);
}
f1();
fv += 42;
f2v += 36;
}

f2a(3);

}
}

would be translated as (in a C-like syntax without nested function and with
the dynamic link handled by the C compiler if one is needed):

struct __f_frame {
int fv;
};

struct __f2_frame {
struct __f_frame* parent;
int f2v;
}

void f1(struct __f_frame* parent) {
use(parent->fv);
}

void f2a(struct __f2_frame* parent, int r) {
if (r != 0) {
f2a(parent, r-1);
}
f1(parent->parent);
parent->parent->fv += 42;
parent->f2v += 36;
}

void f2(struct __f_frame* parent) {
struct __f2_frame local_frame;
local_frame.parent = parent;
f2a(&local_frame, 3);
}

void f() {
struct __f_frame local_frame;
f2(&local_frame);
}

Yours,

--
Jean-Marc

Re: Secrets of the ancients, What the World Needs Now

<86h6jwsstt.fsf@linuxsc.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=36468&group=comp.arch#36468

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17687@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: Secrets of the ancients, What the World Needs Now
Date: Mon, 01 Jan 2024 12:26:54 -0800
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <86h6jwsstt.fsf@linuxsc.com>
References: <uletbu$19ohv$1@dont-email.me> <ulml73$10fu3$1@newsreader4.netcologne.de> <uln60k$2m9s$1@gal.iecc.com> <uln86f$10rpl$1@newsreader4.netcologne.de> <ulnj9g$2719$1@gal.iecc.com> <uls9ri$144lp$1@newsreader4.netcologne.de> <kue2p4FbsrjU1@mid.individual.net> <2023Dec19.191250@mips.complang.tuwien.ac.at> <kuegl7FbsrjU2@mid.individual.net> <ulusjs$j0q5$3@dont-email.me> <ulvac2$l7hl$1@dont-email.me> <2023Dec20.194712@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="4ad5b29cc5222e274263b40ba81c3fd0";
logging-data="2448775"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19/0S26dodzMwXij21vbt/W7h4s6VQtFck="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:zzFpRQOfwlBJT2P4FRBJGnAKvrk=
sha1:qAaqWgdqrZDSH03RQfS3k+OSwk8=
 by: Tim Rentsch - Mon, 1 Jan 2024 20:26 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:

[...]

> Modula-2 has nested procedures, and allows putting procedures in
> variables, fields, etc., but eliminates the upward funarg problem by
> only allowing to store global-level procedures in variables, not
> nested procedures. So it went closer to C.
>
> Oberon originally had nested procedures, and AFAIK similar rules to
> Modula-2. When I asked Wirth in 2020 if he has a good example for the
> use of nested procedures (I thought he would have, given that he kept
> this feature for so many years), he told me that he had removed nested
> functions in 2013 or so.

There is a significant benefit to well-done nested functions, where
well-done means full closures, syntactically lightweight, and
allowing an anonymous expressional form, often called a lambda:
the ability to define first-class control structures in the
language, rather than needing control structures built into the
language. See for example blocks in Smalltalk.

Re: What the World Needs Now

<un32rp$34ha9$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=36540&group=comp.arch#36540

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: quadibloc@servername.invalid (Quadibloc)
Newsgroups: comp.arch
Subject: Re: What the World Needs Now
Date: Wed, 3 Jan 2024 07:37:30 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <un32rp$34ha9$1@dont-email.me>
References: <uletbu$19ohv$1@dont-email.me>
<5c7dd089ac74ea85a07413b08347a333@news.novabbs.com>
<ulhnu1$1u7kj$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 3 Jan 2024 07:37:30 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b4308625883b56efd26d7955d78f84ab";
logging-data="3294537"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19xTzbNVUaOSIhiIlYzeaizQMgItczdYxU="
User-Agent: Pan/0.146 (Hic habitat felicitas; d7a48b4
gitlab.gnome.org/GNOME/pan.git)
Cancel-Lock: sha1:uQWbXZWvCp9PUN814xGJlC4GqVM=
 by: Quadibloc - Wed, 3 Jan 2024 07:37 UTC

On Fri, 15 Dec 2023 14:30:25 +0000, Quadibloc wrote:

> Is the CPU even the place for sandboxing? A genuinely effective sandbox
> would involve a physical separation between the protected computer and
> the one connected to the Internet, after all. But that isn't
> convenient...

In a different thread, I've finally fleshed this out.

One has the "real" computer, which is built for speed, and which may
therefore have some limitations to its security. So that computer isn't
connected directly to the Internet.

But it controls a subordinate computer which does connect to the Internet.

That computer should be completely unable to write to the only memory it
is capable of loading executable code from. Instead, its parent, the real
computer, loads all executable code into that memory.

This scheme was used by the old Bell system Electronic Switching System,
and I think that it produces pretty good security.

That computer would then have a subordinate computer of its own. This
third computer is used to run things like the implementation of JavaScript
with a just-in-time compiler. It uses 486-style tecnology; that is, its
an in-order processor (no Spectre) running slowly enough that its DRAM
is not subject to Rowhammer.

So a malicious web site would have to execute vulnerabilities created by
software bugs inside the third computer, and these would presumably ge
gradually eliminated as attacks are detected. It wouldn't have the
hardware vulnerabilities which are difficult to get rid of to use.

And then, in order to get at the hard drives of the computer, it would have
to attack the "real" computer at the top level. But between it and that is
a computer with zero ability to execute code that it can write or modify.

To me, that seems like a desert that malware can't cross. (A vulerability
could be created, of course, if the second computer was allowed to execute
external programs by means of an _interpreter_ instead of a just-in-time
compiler. So making interpreters available within the secondary computer
that talks to the Internet must be recognized as a practice to avoid.)

John Savard

Re: Secrets of the ancients, What the World Needs Now

<87f8e8bc9c4797640c63c3544403c1d3@news.novabbs.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=36566&group=comp.arch#36566

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!.POSTED!not-for-mail
From: mitchalsup@aol.com (MitchAlsup)
Newsgroups: comp.arch
Subject: Re: Secrets of the ancients, What the World Needs Now
Date: Wed, 3 Jan 2024 17:57:23 +0000
Organization: novaBBS
Message-ID: <87f8e8bc9c4797640c63c3544403c1d3@news.novabbs.com>
References: <uletbu$19ohv$1@dont-email.me> <ulml73$10fu3$1@newsreader4.netcologne.de> <uln60k$2m9s$1@gal.iecc.com> <uln86f$10rpl$1@newsreader4.netcologne.de> <ulnj9g$2719$1@gal.iecc.com> <uls9ri$144lp$1@newsreader4.netcologne.de> <kue2p4FbsrjU1@mid.individual.net> <2023Dec19.191250@mips.complang.tuwien.ac.at> <kuegl7FbsrjU2@mid.individual.net> <ulusjs$j0q5$3@dont-email.me> <ulvac2$l7hl$1@dont-email.me> <2023Dec20.194712@mips.complang.tuwien.ac.at> <86h6jwsstt.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="2151448"; mail-complaints-to="usenet@i2pn2.org";
posting-account="t+lO0yBNO1zGxasPvGSZV1BRu71QKx+JE37DnW+83jQ";
User-Agent: Rocksolid Light
X-Spam-Checker-Version: SpamAssassin 4.0.0
X-Rslight-Site: $2y$10$ZBICs0.M3HLgJCxzrR1gk.Jg5R2lgam7p8amfRgbXTxymAanGU6rq
X-Rslight-Posting-User: 7e9c45bcd6d4757c5904fbe9a694742e6f8aa949
 by: MitchAlsup - Wed, 3 Jan 2024 17:57 UTC

Tim Rentsch wrote:

> There is a significant benefit to well-done nested functions, where
> well-done means full closures, syntactically lightweight, and
> allowing an anonymous expressional form, often called a lambda:
> the ability to define first-class control structures in the
> language, rather than needing control structures built into the
> language. See for example blocks in Smalltalk.

How do pointers to nested functions interact with try-throw-catch ??

Do you use the stack as it is now ?? or how it was when the closure was
constructed ??

Re: Secrets of the ancients, What the World Needs Now

<un4g74$2icf$1@gal.iecc.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=36575&group=comp.arch#36575

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!1.us.feeder.erje.net!feeder.erje.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED.news.iecc.com!not-for-mail
From: johnl@taugh.com (John Levine)
Newsgroups: comp.arch
Subject: Re: Secrets of the ancients, What the World Needs Now
Date: Wed, 3 Jan 2024 20:31:32 -0000 (UTC)
Organization: Taughannock Networks
Message-ID: <un4g74$2icf$1@gal.iecc.com>
References: <uletbu$19ohv$1@dont-email.me> <2023Dec20.194712@mips.complang.tuwien.ac.at> <86h6jwsstt.fsf@linuxsc.com> <87f8e8bc9c4797640c63c3544403c1d3@news.novabbs.com>
Injection-Date: Wed, 3 Jan 2024 20:31:32 -0000 (UTC)
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
logging-data="84367"; mail-complaints-to="abuse@iecc.com"
In-Reply-To: <uletbu$19ohv$1@dont-email.me> <2023Dec20.194712@mips.complang.tuwien.ac.at> <86h6jwsstt.fsf@linuxsc.com> <87f8e8bc9c4797640c63c3544403c1d3@news.novabbs.com>
Cleverness: some
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: johnl@iecc.com (John Levine)
Lines: 23
 by: John Levine - Wed, 3 Jan 2024 20:31 UTC

According to MitchAlsup <mitchalsup@aol.com>:
>Tim Rentsch wrote:
>
>> There is a significant benefit to well-done nested functions, where
>> well-done means full closures, ...

>How do pointers to nested functions interact with try-throw-catch ??
>
>Do you use the stack as it is now ?? or how it was when the closure was
>constructed ??

The usual answer is that you unwind the stack to its state at try, and
if you then call something that uses stack frames below that, you
lose.

Or you can do spaghetti stacks, where the stack can be forked and you
keep all the frames around that might be reactivated. See Scheme and
Smalltalk.

--
Regards,
John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly

Re: Secrets of the ancients, What the World Needs Now

<0d62169e7c2ee3ddbbee0446dc4e79f1@news.novabbs.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=36581&group=comp.arch#36581

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!.POSTED!not-for-mail
From: mitchalsup@aol.com (MitchAlsup)
Newsgroups: comp.arch
Subject: Re: Secrets of the ancients, What the World Needs Now
Date: Wed, 3 Jan 2024 22:43:40 +0000
Organization: novaBBS
Message-ID: <0d62169e7c2ee3ddbbee0446dc4e79f1@news.novabbs.com>
References: <uletbu$19ohv$1@dont-email.me> <2023Dec20.194712@mips.complang.tuwien.ac.at> <86h6jwsstt.fsf@linuxsc.com> <87f8e8bc9c4797640c63c3544403c1d3@news.novabbs.com> <un4g74$2icf$1@gal.iecc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="2176764"; mail-complaints-to="usenet@i2pn2.org";
posting-account="t+lO0yBNO1zGxasPvGSZV1BRu71QKx+JE37DnW+83jQ";
User-Agent: Rocksolid Light
X-Spam-Checker-Version: SpamAssassin 4.0.0
X-Rslight-Site: $2y$10$wxqYUK75mYsDqx98CYsuZOGPWSJoGAMKlsSxuEd4H7TQ4077.P9ZS
X-Rslight-Posting-User: 7e9c45bcd6d4757c5904fbe9a694742e6f8aa949
 by: MitchAlsup - Wed, 3 Jan 2024 22:43 UTC

John Levine wrote:

> According to MitchAlsup <mitchalsup@aol.com>:
>>Tim Rentsch wrote:
>>
>>> There is a significant benefit to well-done nested functions, where
>>> well-done means full closures, ...

>>How do pointers to nested functions interact with try-throw-catch ??
>>
>>Do you use the stack as it is now ?? or how it was when the closure was
>>constructed ??

> The usual answer is that you unwind the stack to its state at try, and
> if you then call something that uses stack frames below that, you
> lose.

> Or you can do spaghetti stacks, where the stack can be forked and you
> keep all the frames around that might be reactivated. See Scheme and
> Smalltalk.

Thanks.

Re: Secrets of the ancients, What the World Needs Now

<86cyuhpumd.fsf@linuxsc.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=36594&group=comp.arch#36594

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17687@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: Secrets of the ancients, What the World Needs Now
Date: Wed, 03 Jan 2024 20:53:14 -0800
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <86cyuhpumd.fsf@linuxsc.com>
References: <uletbu$19ohv$1@dont-email.me> <ulml73$10fu3$1@newsreader4.netcologne.de> <uln60k$2m9s$1@gal.iecc.com> <uln86f$10rpl$1@newsreader4.netcologne.de> <ulnj9g$2719$1@gal.iecc.com> <uls9ri$144lp$1@newsreader4.netcologne.de> <kue2p4FbsrjU1@mid.individual.net> <2023Dec19.191250@mips.complang.tuwien.ac.at> <kuegl7FbsrjU2@mid.individual.net> <ulusjs$j0q5$3@dont-email.me> <ulvac2$l7hl$1@dont-email.me> <2023Dec20.194712@mips.complang.tuwien.ac.at> <86h6jwsstt.fsf@linuxsc.com> <87f8e8bc9c4797640c63c3544403c1d3@news.novabbs.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="672bd22e7372e7cd28625c54c459a735";
logging-data="3737573"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Ch6PKBdu6MK/6dwmOJqiQoq40gSPdVLs="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:1HwudXxY6PhqtbgM8HonImjQ2hQ=
sha1:dRddTcl7X2S/erScgt1sbpSc2/g=
 by: Tim Rentsch - Thu, 4 Jan 2024 04:53 UTC

mitchalsup@aol.com (MitchAlsup) writes:

> Tim Rentsch wrote:
>
>> There is a significant benefit to well-done nested functions, where
>> well-done means full closures, syntactically lightweight, and
>> allowing an anonymous expressional form, often called a lambda:
>> the ability to define first-class control structures in the
>> language, rather than needing control structures built into the
>> language. See for example blocks in Smalltalk.
>
> How do pointers to nested functions interact with try-throw-catch ??
>
> Do you use the stack as it is now ?? or how it was when the closure was
> constructed ??

I see you got your question answered. That's good.

Note that Smalltalk doesn't have exceptions built into the
language. When exceptions were added to the Smalltalk
environment, no changes were needed to the language or
the VM - just defining some methods in the right places.

Re: Secrets of the ancients, What the World Needs Now

<2024Jan4.091705@mips.complang.tuwien.ac.at>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=36600&group=comp.arch#36600

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: Secrets of the ancients, What the World Needs Now
Date: Thu, 04 Jan 2024 08:17:05 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 51
Message-ID: <2024Jan4.091705@mips.complang.tuwien.ac.at>
References: <uletbu$19ohv$1@dont-email.me> <2023Dec20.194712@mips.complang.tuwien.ac.at> <86h6jwsstt.fsf@linuxsc.com> <87f8e8bc9c4797640c63c3544403c1d3@news.novabbs.com> <un4g74$2icf$1@gal.iecc.com>
Injection-Info: dont-email.me; posting-host="8fb1d67506df1ec5fbbf30451372e7b6";
logging-data="3793200"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/EJ+xyzoWyklvgTXvHo7PD"
Cancel-Lock: sha1:PThCOq+K4kE9mn22vUY3fXsO2Og=
X-newsreader: xrn 10.11
 by: Anton Ertl - Thu, 4 Jan 2024 08:17 UTC

John Levine <johnl@taugh.com> writes:
>According to MitchAlsup <mitchalsup@aol.com>:
>>Tim Rentsch wrote:
>>
>>> There is a significant benefit to well-done nested functions, where
>>> well-done means full closures, ...
>
>>How do pointers to nested functions interact with try-throw-catch ??
>>
>>Do you use the stack as it is now ?? or how it was when the closure was
>>constructed ??
>
>The usual answer is that you unwind the stack to its state at try, and
>if you then call something that uses stack frames below that, you
>lose.

It's not clear to me what you mean with "below", but anyway:

In the usual exception-handling variant (as exists in, e.g., Java)
where you cannot continue at the throwing site, you just restore
setup, including the stack pointer and the frame pointer (and thus
the static and the dynamic link) to what it was at the "try". The
same holds for Pascal's goto to a label in a statically surrounding
procedure; the more usual exception mechanisms find the try-catch
block dynamically, but that makes no difference after the target of
the throw has been determined.

If the static link was invalid after the "try", it was invalid before
the "try", too; many languages and their implementations are designed
to avoid that, either by preventing closures that live after the
procedure that created them has finished (e.g., Pascal and Modula-2),
or by keeping such closures in garbage-collected memory rather than
the stack (e.g., Scheme).

>Or you can do spaghetti stacks, where the stack can be forked and you
>keep all the frames around that might be reactivated. See Scheme and
>Smalltalk.

From the viewpoint of what to do that's pretty similar to the case
above: if the catch block can decide to continue at the throwing
place, before entering the catch block, the frame pointer is restored
to where it was at the "try", but the stack pointer is not. If the
catch block decides to continue at the throw, the frame pointer (and
the stack pointer, if changed in the meantime) is restored to the
value at the throw; If the catch block decides to continue after the
catch block, the stack pointer is restored to the depth at the "try".

- anton
--
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>

Re: Secrets of the ancients, What the World Needs Now

<s8repilclia44vr86cqtl4vde3q7lr86om@4ax.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=36627&group=comp.arch#36627

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!.POSTED!not-for-mail
From: gneuner2@comcast.net (George Neuner)
Newsgroups: comp.arch
Subject: Re: Secrets of the ancients, What the World Needs Now
Date: Thu, 04 Jan 2024 22:07:51 -0500
Organization: i2pn2 (i2pn.org)
Message-ID: <s8repilclia44vr86cqtl4vde3q7lr86om@4ax.com>
References: <uletbu$19ohv$1@dont-email.me> <2023Dec20.194712@mips.complang.tuwien.ac.at> <86h6jwsstt.fsf@linuxsc.com> <87f8e8bc9c4797640c63c3544403c1d3@news.novabbs.com> <un4g74$2icf$1@gal.iecc.com> <2024Jan4.091705@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Info: i2pn2.org;
logging-data="2316718"; mail-complaints-to="usenet@i2pn2.org";
posting-account="h5eMH71iFfocGZucc+SnA0y5I+72/ecoTCcIjMd3Uww";
User-Agent: ForteAgent/8.00.32.1272
X-Spam-Checker-Version: SpamAssassin 4.0.0
 by: George Neuner - Fri, 5 Jan 2024 03:07 UTC

On Thu, 04 Jan 2024 08:17:05 GMT, anton@mips.complang.tuwien.ac.at
(Anton Ertl) wrote:

>John Levine <johnl@taugh.com> writes:
>>According to MitchAlsup <mitchalsup@aol.com>:
>>>Tim Rentsch wrote:
>>>
>>>> There is a significant benefit to well-done nested functions, where
>>>> well-done means full closures, ...
>>
>>>How do pointers to nested functions interact with try-throw-catch ??
>>>
>>>Do you use the stack as it is now ?? or how it was when the closure was
>>>constructed ??
>>
>>The usual answer is that you unwind the stack to its state at try, and
>>if you then call something that uses stack frames below that, you
>>lose.
>
>It's not clear to me what you mean with "below", but anyway:

Functions defined in scopes enclosed by the function containing the
"try".

The stack POV is reversed: the frame for function containing the "try"
would be lower in the stack, and frames for any enclosed functions
would be higher (closer to the top) in the stack.

>In the usual exception-handling variant (as exists in, e.g., Java)
>where you cannot continue at the throwing site, you just restore
>setup, including the stack pointer and the frame pointer (and thus
>the static and the dynamic link) to what it was at the "try". The
>same holds for Pascal's goto to a label in a statically surrounding
>procedure; the more usual exception mechanisms find the try-catch
>block dynamically, but that makes no difference after the target of
>the throw has been determined.

But that won't necessarily work in a language like Scheme where a
saved closure might use functions enclosed by the "try".
[Depends on the implementation of closures.]

>If the static link was invalid after the "try", it was invalid before
>the "try", too; many languages and their implementations are designed
>to avoid that, either by preventing closures that live after the
>procedure that created them has finished (e.g., Pascal and Modula-2),
>or by keeping such closures in garbage-collected memory rather than
>the stack (e.g., Scheme).

The static link is not invalid after the try - but it MAY become
invalid after a throw.

>>Or you can do spaghetti stacks, where the stack can be forked and you
>>keep all the frames around that might be reactivated. See Scheme and
>>Smalltalk.

As John mentioned, one possible implementation of closures is to
preserve the stack frames that are referenced [note: not necessarily
the whole call chain - just the referenced scope chain]. Static links
within the preserved chain of frames would remain valid.

>From the viewpoint of what to do that's pretty similar to the case
>above: if the catch block can decide to continue at the throwing
>place, before entering the catch block, the frame pointer is restored
>to where it was at the "try", but the stack pointer is not. If the
>catch block decides to continue at the throw, the frame pointer (and
>the stack pointer, if changed in the meantime) is restored to the
>value at the throw; If the catch block decides to continue after the
>catch block, the stack pointer is restored to the depth at the "try".

Microsoft's Structured Exception Handling (SEH) includes the ability
to continue from the exception point.

Lisp exceptions include the ability to continue from multiple
(re-entry) points following the throw.

>- anton

Re: Nested functions and representation of closures

<unartm$gu1g$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=36652&group=comp.arch#36652

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: cr88192@gmail.com (BGB)
Newsgroups: comp.arch
Subject: Re: Nested functions and representation of closures
Date: Sat, 6 Jan 2024 00:28:04 -0600
Organization: A noiseless patient Spider
Lines: 108
Message-ID: <unartm$gu1g$1@dont-email.me>
References: <uletbu$19ohv$1@dont-email.me> <ulnj9g$2719$1@gal.iecc.com>
<uls9ri$144lp$1@newsreader4.netcologne.de> <kue2p4FbsrjU1@mid.individual.net>
<2023Dec19.191250@mips.complang.tuwien.ac.at>
<kuegl7FbsrjU2@mid.individual.net> <ulusjs$j0q5$3@dont-email.me>
<ulvac2$l7hl$1@dont-email.me> <2023Dec20.194712@mips.complang.tuwien.ac.at>
<4bab9ad8e39f0b0c1610a7549478c9ac@news.novabbs.com>
<2023Dec20.223744@mips.complang.tuwien.ac.at>
<jwva5q4bjqs.fsf-monnier+comp.arch@gnu.org>
<2023Dec21.074154@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 6 Jan 2024 06:28:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d268f31930337ed8bc70871f592e946b";
logging-data="555056"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+L7A+Pj7GS+6u9ShWSLdLO"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:ZbzSQfVSb39H5XTd4aWES/b6fZE=
Content-Language: en-US
In-Reply-To: <2023Dec21.074154@mips.complang.tuwien.ac.at>
 by: BGB - Sat, 6 Jan 2024 06:28 UTC

On 12/21/2023 12:41 AM, Anton Ertl wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> Anton Ertl [2023-12-20 21:37:44] wrote:
>>> mitchalsup@aol.com (MitchAlsup) writes:
>>>> Anton Ertl wrote:
>>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> writes:
>>>>>> I believe Pascal, back in the 1970s implemented nested functions, though
>>>>>> I don't know how any specific implementation accomplished it.
>>>>> AFAIK Pascal implementations all just use static links chains to the
>>>>> enclosing scopes. So you access an outer local by following the link
>>>>> chain as many levels as you cross scopes.
>>>> How does Pascal do this counting when there are recursive frames on
>>>> the stack ??
>>> The static scope level is independent of recursion. Note that this
>>> kind of implementation has a static link in addition to the dynamic
>>> link.
>>
>> Maybe I'm missing something but I think Pascal's display is "orthogonal"
>> to the issue discussed before of how to stuff together a code pointer
>> together with a pointer to its associated data.
>
> Certainly. For example, AFAIK Pascal implementations do not use a
> display, but just follows static links (but maybe somebody with more
> knowledge can correct me). Cohen [cohen91] described how to use a
> display for type inclusion tests. IIRC Wirth wrote a letter in reply
> where he stated that he had tried to use a display for accessing outer
> locals around 1970, but found that it hurt performance, and that he
> was happy that this technique was useful for something after all.
>
> @Article{cohen91,
> author = "Norman H. Cohen",
> title = "Type-Extension Type Tests Can Be Performed In Constant
> Time",
> journal = "ACM Transactions on Programming Languages and
> Systems",
> volume = "13",
> number = "4",
> pages = "626--629",
> month = oct,
> year = "1991",
> refs = "2",
> checked = "19940624",
> source = "Dept. Library",
> keywords = "class, descriptor, display, extensible data type,
> inheritance, membership test, object-oriented
> programming, type extension, type test",
> note = "Technical Correspondence",
> abstract = "Wirth's proposal for type extensions includes an
> algorithm for determining whether a give value belongs
> to an extension of a given type. In the worst case,
> this algorithm takes time proportional to the depth of
> the type-extension hierarchy. Wirth describes the loop
> in this algorithm as ``unavoidable,'' but in fact, the
> test can be performed in constant time by associating a
> ``display'' of base types with each type descriptor.",
> xref = "Wirth:acm:toplas:1988",
> reffrom = "Corney:Gough:plasa:1994",
> }
>
>> Pascal's display is one possible representation of closures, but it
>> doesn't save you from the need to use a kind of "fat pointer" for the
>> first-class functions.
>
> Correct.
>
>> What saves Pascal is that first-class functions aren't first class at
>> all, so Pascal can safely and easily represent them any way it likes,
>> including as a pair of two values (a pointer to the code, and a pointer
>> to a stack frame, typically).
>
> Even first-class closures are not a problem. The easiest way is to
> let them be a type of two machine words, a code pointer and an
> environment pointer.
>
>> It's harder in C because some code wants to be able to convert
>> a function pointer to a `void*` and back, so you usually want to make it
>> fit into the size of a normal pointer.
>
> Even first class closures that are represented in one machine word are
> not a problem. Just box the two words and pass a pointer to that box.
>
> The problem is an ABI that passes function pointers as code pointers
> and where calling a function pointer performs an indirect call to the
> passed pointer. I.e., a typical C ABI.
>

In my case, I have function pointers as narrow code pointers, and also
closures (as a C language extension), which look just like normal
function pointers.

Though the current implementation is that a closure is a pointer to a
blob of machine code that loads its own address into a designated
register and then branches to the actual entry point for the function
(with the captured bindings for the closure following the machine-code
blob).

Granted, this implementation still favors non-closure function pointers
as the default case.

At present, this was implemented by having a mechanism to allocate RWE
memory objects (via one of the special case values passed to
"_malloc_cat()").

> - anton

Pages:1234
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor