[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: new function
From: |
Taylan Kammer |
Subject: |
Re: new function |
Date: |
Thu, 23 Sep 2021 21:03:19 +0200 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 |
On 22.09.2021 23:52, William ML Leslie wrote:
> On Thu, 23 Sep 2021, 4:51 am Taylan Kammer, <taylan.kammer@gmail.com
> <mailto:taylan.kammer@gmail.com>> wrote:
>
> On 22.09.2021 11:53, Damien Mattei wrote:
> > i already do it this way for internal defines ,using a recursive macro
> that build a list of variable using an accumulator. It can works but macro
> expansion seems slow, it was not immediate at compilation on a little example
> (oh nothing more that 2 seconds) but i'm not sure it is easily maintainable,
> it is at the limit what macro can do i think ,for speed reasons. In fact i
> can not really understand in Guile as it is based on C and compiled when
> macro expansion happens,what is the time cost... so for all those ,perhaps
> not objective reason ,i prefer to avoid.
>
> I don't think there's any other way to achieve what you want, especially
> using portable Scheme code. The lexical scoping semantics of Scheme are
> a very fundamental part of the language, and cannot be worked around in
> portable Scheme code without using a macro that rewrites whole bodies of
> lambda expressions.
>
> Even using implementation-specific hacks, you won't get very far. Any
> compiled Scheme implementation, and even most interpreted ones, won't
> allow you to modify an outer scope's set of variable definitions from
> within an inner scope.
>
> So if you really want to have Python's scoping semantics in Scheme, you
> will probably have to write a complex 'def' macro that walks through the
> body and "hoists" variable definitions to the outermost scope.
>
>
> Python is lexically scoped, and the assignment here is supposed to be local.
Well, yes and no. It implements variable hoisting, meaning all previously
unset variables that are set within a function are implicitly declared at the
beginning of the function. It doesn't have sub-scopes in function bodies.
--
Taylan
- Re: new function, (continued)
- Re: new function, Matt Wette, 2021/09/19
- Re: new function, Taylan Kammer, 2021/09/19
- Re: new function, Damien Mattei, 2021/09/21
- Re: new function, Damien Mattei, 2021/09/22
- Re: new function, William ML Leslie, 2021/09/22
- Re: new function, Damien Mattei, 2021/09/22
- Re: new function, Taylan Kammer, 2021/09/22
- Re: new function, William ML Leslie, 2021/09/22
- Re: new function, Damien Mattei, 2021/09/23
- Re: new function,
Taylan Kammer <=
- Re: new function, Damien Mattei, 2021/09/23
- Re: new function, Maxime Devos, 2021/09/23
- Re: new function, Taylan Kammer, 2021/09/23
- Re: new function, Damien Mattei, 2021/09/23
- Re: new function, Taylan Kammer, 2021/09/23
- Re: new function, Damien Mattei, 2021/09/23
- Re: new function, Damien Mattei, 2021/09/24