Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-21 Thread Kirill Balunov
пн, 20 авг. 2018 г. в 17:23, Steven D'Aprano : > On Sun, Aug 19, 2018 at 06:18:56PM +0300, Kirill Balunov wrote: > [...] > [Kirill] > > Let me disagree with you. While CPython is only one of the > implementations > > of the Python language, it is the most common one and defacto is > considered >

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-20 Thread Rhodri James
On 20/08/18 17:16, Chris Barker via Python-ideas wrote: On Mon, Aug 20, 2018 at 7:21 AM, Steven D'Aprano wrote: * Introducing a warning makes it clear that this is not a de facto language standard, but a mere implementation detail subject to change if somebody comes up with a better

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-20 Thread Chris Angelico
On Tue, Aug 21, 2018 at 2:16 AM, Chris Barker via Python-ideas wrote: > On Mon, Aug 20, 2018 at 7:21 AM, Steven D'Aprano > wrote: >> >> * Introducing a warning makes it clear that this is not a de facto >> language standard, but a mere implementation detail subject to >> change if somebody

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-20 Thread Chris Barker via Python-ideas
On Mon, Aug 20, 2018 at 7:21 AM, Steven D'Aprano wrote: > * Introducing a warning makes it clear that this is not a de facto > language standard, but a mere implementation detail subject to > change if somebody comes up with a better optimization for locals. > defacto standards are

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-20 Thread Jonathan Fine
Hi I've created new thread === Documentation of locals() https://mail.python.org/pipermail/python-ideas/2018-August/052843.html Summary: There's prior art in bug.python.org relating to off-thread topic discussion of locals(). Suggest work on closing open documentation issues relating to

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-20 Thread Chris Angelico
On Tue, Aug 21, 2018 at 12:21 AM, Steven D'Aprano wrote: > On Sun, Aug 19, 2018 at 06:18:56PM +0300, Kirill Balunov wrote: > > [...] >> > > e) It leaves a room for a future changes (In fact, in some situations I >> > > would like to have this possibility). > > [Chris] >> > Related to (e) is that

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-20 Thread Steven D'Aprano
On Sun, Aug 19, 2018 at 06:18:56PM +0300, Kirill Balunov wrote: [...] > > > e) It leaves a room for a future changes (In fact, in some situations I > > > would like to have this possibility). [Chris] > > Related to (e) is that there is room for other implementations to > > permit changes to

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-19 Thread Kirill Balunov
вс, 19 авг. 2018 г. в 17:51, Chris Angelico : > On Mon, Aug 20, 2018 at 12:43 AM, Kirill Balunov > wrote: > > > [...] > > I have the same feeling and already have asked the same question before > > https://mail.python.org/pipermail/python-list/2018-February/731241.html. > The > > main take away

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-19 Thread Chris Angelico
On Mon, Aug 20, 2018 at 12:43 AM, Kirill Balunov wrote: > > чт, 16 авг. 2018 г. в 22:37, Chris Barker via Python-ideas > : >> >> >> I wonder why locals doesn't return a Mapping Proxy, or other read-only >> mapping object? >> >> If it's not guaranteed to be THE locals dict, and changes *may* not

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-19 Thread Kirill Balunov
чт, 16 авг. 2018 г. в 22:37, Chris Barker via Python-ideas < python-ideas@python.org>: > > I wonder why locals doesn't return a Mapping Proxy, or other read-only > mapping object? > > If it's not guaranteed to be THE locals dict, and changes *may* not affect > the real one (but may), a read-only

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-17 Thread Abe Dillon
Is "Ban" a class of morphemes or just a single morpheme? I would think subclasses of Morpheme would be "Bound" and "Unbound" then there might be subclasses of Bound and so on. [Jacob Solinsky] > now I understand that the best way to do that would just be to macro > expand an often repeated

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-17 Thread Chris Barker - NOAA Federal via Python-ideas
By the way— really kludgy, doesn’t exec() do what you want here: Note The default *locals* act as described for function locals() below: modifications to the default *locals* dictionary should not be attempted. Pass an explicit

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-17 Thread Jacob Solinsky
The code does the following 2 things: A Verb class assembles the necessary morphemes in order in accordance with the verb's subject, object, mode, grmamatical order, tense and polarity. If all of the morphemes' default forms were mashed together at this point a valid Ojibwe verb form would not be

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-17 Thread Abe Dillon
Jacob, can you please describe in greater detail *what* you're trying to accomplish with your morpheme code? Not *how* you wish to accomplish it, but *what* the code is supposed to do? I've looked into other projects that try to model morphemes and similar language constructs to get a better idea

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-17 Thread Chris Barker via Python-ideas
On Thu, Aug 16, 2018 at 12:37 PM, Chris Angelico wrote: > > I've no idea what interpreter you're using, but it doesn't work for me. > That was in iPython, with python3.6.2 -- I wouldn't have expected it to be different in this case though -- really odd. OK -- tired again, and it indeed it

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-17 Thread Jonathan Fine
Jacob Solinsky wrote: > So when getx is executed inside a let form, if it tries to read/write the > value of X it interacts with the X entry in the let form's symbol table > before moving to find X in the global environment, right? The context for this is two (very useful) URLs I sent him off

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-17 Thread Brice Parent
Le 16/08/2018 à 20:34, Steven D'Aprano a écrit : On Thu, Aug 16, 2018 at 10:31:28AM +0200, Brice Parent wrote: If I understand well the need (I'm unsure I've had it myself), it would be easier to be able to import the function in the active context, like this: def foo(a):     return a + c

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-17 Thread Stephen J. Turnbull
Jacob Solinsky writes: > I think the way a "jump to" function rather than a "call function" would be > implemented would be by removing the prologue and epilogue of the > function's compiled code. Something vaguely like this: First, let me apologize for pointing you at Ruby blocks. They

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Chris Angelico
On Fri, Aug 17, 2018 at 5:32 AM, Chris Barker via Python-ideas wrote: > hmm -- made me think that generators are doing something different here -- > and indeed they are. If you use regular functions: > > In [30]: def local_modifying(loc): > ...: """ > ...: adds a "fred" key to the

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Chris Barker via Python-ideas
one more thought: given that: > > The contents of this dictionary should not be modified; changes may not >> affect the values of local and free variables used by the interpreter. >> > > and: > """ > locals() > > Update and return a dictionary representing the current local symbol table. > I

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Chris Barker via Python-ideas
On Thu, Aug 16, 2018 at 10:33 AM, Jonathan Fine wrote: > >> there > >> are times where I have really wanted to access the caller's environment, > >> not the environment where my function was defined. > > > what am I missing? can't you get that by passing locals() in to a > function? > > I think

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Steven D'Aprano
On Thu, Aug 16, 2018 at 09:34:57AM -0700, Chris Barker wrote: > On Thu, Aug 16, 2018 at 1:28 AM, Steven D'Aprano > wrote: > > > there > > are times where I have really wanted to access the caller's environment, > > not the environment where my function was defined. > > > > what am I missing?

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Steven D'Aprano
On Thu, Aug 16, 2018 at 10:31:28AM +0200, Brice Parent wrote: > If I understand well the need (I'm unsure I've had it myself), it would > be easier to be able to import the function in the active context, like > this: > > def foo(a): >     return a + c > > def bar(a, c): >     return foo(a) >

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Stephen J. Turnbull
Jacob Solinsky writes: > What I had hoped to do was use a preamble code block to collect all of the > most common queries called by the mutate function in the local namespace, > for example > > C = 'bpgkdtszSZjCmnywh' > M = 'mn' > > > class Morpheme: > #stuff > > def

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Stephen J. Turnbull
tl;dr A pedantic note on dynamic binding. Steven D'Aprano writes: > The most common language today that uses dynamic scoping is probably > Emacs Lisp. AFAIK all Common-Lisp-ish languages implement dynamic scoping: anything defvar'd is dynamically-scoped. > Although dynamic scoping is very

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Jonathan Fine
Hi Jacob I really like your previous post. I find it really helps me understand what you want. You wrote > I wanted the called, jumped to function to change state in the caller. > From what I tried to do, passing locals() cannot accomplish this. I have > made it happen in other languages though.

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Jacob Solinsky
On Thu, 16 Aug 2018, 12:44 Jacob Solinsky, wrote: > I wanted the called, jumped to function to change state in the caller. > From what I tried to do, passing locals() cannot accomplish this. I have > made it happen in other languages though. > In the R language, one can do this > > foo =

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Jonathan Fine
Hi Chris Steve and you wrote: >> there >> are times where I have really wanted to access the caller's environment, >> not the environment where my function was defined. > what am I missing? can't you get that by passing locals() in to a function? I think this will fail when values are changed.

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Chris Barker via Python-ideas
On Thu, Aug 16, 2018 at 1:28 AM, Steven D'Aprano wrote: > there > are times where I have really wanted to access the caller's environment, > not the environment where my function was defined. > what am I missing? can't you get that by passing locals() in to a function? A bit clunky, sure, but

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Brice Parent
If I understand well the need (I'm unsure I've had it myself), it would be easier to be able to import the function in the active context, like this: def foo(a):     return a + c def bar(a, c):     return foo(a) def bazz(a, c):     import __file__.foo     return foo(a) c = 5 call = bar(1,

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Steven D'Aprano
On Wed, Aug 15, 2018 at 09:58:28PM -0400, David Mertz wrote: > When did you last read the Dijkstra paper. It's short and he explains very > well why exactly all the constructs you mention are unlike Goto. Of course I've read it, and no he does not. He only mentions if...else and looping. He

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-15 Thread David Mertz
When did you last read the Dijkstra paper. It's short and he explains very well why exactly all the constructs you mention are unlike Goto. This isn't a proposal to subroutines, it's a proposal for subroutines in which all lexically scoped variables are implicitly nonlocal. That's basically Goto,

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-15 Thread Steven D'Aprano
On Wed, Aug 15, 2018 at 08:35:35PM -0400, David Mertz wrote: > Goto considered harmful. Fortunately this proposal has nothing to do with goto. Elazar is correct that its a kind of subroutine call, just like an ordinary function call, except the scoping rules are different. And for the record,

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-15 Thread Abe Dillon
[Jacob Solinsky] > these local variables are used quite often in the mutate methods, of which > there are several dozen, so storing them by default saves a lot of typing. There are several things you can do to alleviate the typing problem: 1) Get an IDE that has auto-complete. I recommend

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-15 Thread Steven D'Aprano
On Wed, Aug 15, 2018 at 01:52:27PM -0500, Jacob Solinsky wrote: > -Jumping to a function as opposed to calling a function > > When a function is jumped to, it inherits the variables in the > caller’s local namespace and is free to modify them or add new local > variables, unlike a normal

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-15 Thread Elazar
I have no opinion on the proposal, but the equation with goto is dead wrong. Yes, technically this is a goto. But so is a regular function call. Jumping to a function makes thd code _easier_ to reason about, statically, not harder. When you call an arbitrary function, you have no idea whether it

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-15 Thread Eric Fahlgren
How about just https://homepages.cwi.nl/~storm/teaching/reader/Dijkstra68.pdf On Wed, Aug 15, 2018 at 5:38 PM David Mertz wrote: > Hmm.. link broke. Is this right? > > >

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-15 Thread David Mertz
Hmm.. link broke. Is this right? https://www.google.com/url?sa=t=web=j=https://homepages.cwi.nl/~storm/teaching/reader/Dijkstra68.pdf=2ahUKEwi8lqHYqfDcAhXImOAKHeAzDmsQFjAEegQIBhAB=AOvVaw1CZug_36-PbevItYXTb7SR On Wed, Aug 15, 2018, 8:35 PM David Mertz wrote: > Goto considered harmful. > > >

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-15 Thread David Mertz
Goto considered harmful. https://homepages.cwi.nl/~storm/teaching/reader/Dijkstra68.pdf=2ahUKEwi8lqHYqfDcAhXImOAKHeAzDmsQFjAEegQIBhAB=AOvVaw1CZug_36-PbevItYXTb7SR On Wed, Aug 15, 2018, 3:52 PM Jacob Solinsky wrote: > -Jumping to a function as opposed to calling a function > > When a function

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-15 Thread Chris Angelico
On Thu, Aug 16, 2018 at 8:53 AM, Jacob Solinsky wrote: > What I had hoped to do was use a preamble code block to collect all of the > most common queries called by the mutate function in the local namespace, > for example > > C = 'bpgkdtszSZjCmnywh' > M = 'mn' > > > class Morpheme: > #stuff >

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-15 Thread Jacob Solinsky
What I had hoped to do was use a preamble code block to collect all of the most common queries called by the mutate function in the local namespace, for example C = 'bpgkdtszSZjCmnywh' M = 'mn' class Morpheme: #stuff def preamble(self): ps = self.precedingmorpheme.form ss =

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-15 Thread Abe Dillon
Sorry for the double post, but I wanted to make sure you saw my original misplaced post: Jumping into functions that mutate variables in the calling scope sounds a lot like "GoTo" which is notorious for leading to code that's very hard to reason

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-15 Thread Abe Dillon
[Chris Angelico] > Drop the word "function" and it's no longer about a goto - it's about > a block of code that can be deposited into another context. The only context I've used goto is in a TI-83 scientific calculator, but in that, it was just about jumping around to different labels in code

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-15 Thread Chris Angelico
On Thu, Aug 16, 2018 at 7:40 AM, Abe Dillon wrote: > Jumping into functions that mutate variables in the calling scope sounds a > lot like "GoTo" which is notorious for leading to code that's very hard to > reason about. Your functions would implicitly require that you assign > variables in the

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-15 Thread Abe Dillon
Jumping into functions that mutate variables in the calling scope sounds a lot like "GoTo" which is notorious for leading to code that's very hard to reason about. Your functions would implicitly require that you assign variables in the calling

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-15 Thread Chris Angelico
On Thu, Aug 16, 2018 at 4:52 AM, Jacob Solinsky wrote: > -Jumping to a function as opposed to calling a function > > When a function is jumped to, it inherits the variables in the caller’s local > namespace and is free to modify them or add new local variables, unlike a > normal function call,

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-15 Thread Jonathan Fine
Hi Jacob Thank you for your problem. I'll focus on your simple example (lightly edited for clarity) > Let foo(a, b) be the syntax to call foo(a, b), and foo(a, b)% be the syntax > to jump to foo(a, b) > > c = 5 > > def foo(a): > return a + c > > def bar(a, c): > return foo(a) >