Re: [O] lisp: scoping vars in repetitive defuns

2019-09-18 Thread Adam Porter
John Kitchin writes: > I am not sure why you have to loop over everything in a let statement > though. you can use something like > https://github.com/nicferrier/emacs-kv to get all the keys an loop > over those to do what you want, or you can just use cl-loop to do > that. Recent Emacs

Re: [O] lisp: scoping vars in repetitive defuns

2019-09-18 Thread John Kitchin
I played with a similar idea of converting a plist to something you can call to access values at https://kitchingroup.cheme.cmu.edu/blog/2017/04/16/A-callable-plist-data-structure-for-Emacs/. It did end up as a macro, but no eval required. It never made it past that post, but it might have an

Re: [O] lisp: scoping vars in repetitive defuns

2019-09-18 Thread Adam Porter
Joost Kremers writes: > On Wed, Sep 18 2019, Matt Price wrote: >> Is thre away to do that kind of destructuring bind -- which >> binds *everything* in the plist, without knowing the symbol names in >> advance? that would be really great. > > let-alist perhaps? Well, let-alist is for alists, not

Re: [O] lisp: scoping vars in repetitive defuns

2019-09-18 Thread Adam Porter
Matt Price writes: > This is fun, thanks John. I really like the plist version put would > also like to loop through the variables in a let statement somehow. > > I think what I'm missing is the equivalent of a javascript implicit > destructuring construct: > > let { } = object; > > which will

Re: [O] lisp: scoping vars in repetitive defuns

2019-09-18 Thread Joost Kremers
On Wed, Sep 18 2019, Matt Price wrote: Is thre away to do that kind of destructuring bind -- which binds *everything* in the plist, without knowing the symbol names in advance? that would be really great. let-alist perhaps? -- Joost Kremers Life has its moments

Re: [O] lisp: scoping vars in repetitive defuns

2019-09-18 Thread Matt Price
This is fun, thanks John. I really like the plist version put would also like to loop through the variables in a let statement somehow. I think what I'm missing is the equivalent of a javascript implicit destructuring construct: let { } = object; which will define new variables prop1, prop2...

Re: [O] lisp: scoping vars in repetitive defuns

2019-09-18 Thread John Kitchin
You don't really need a macro for this I think. I see it leads to pretty clean looking code, but as you noted at the expense of edebuggable functions. I don't think you need the lexical-let in your macro though. With empty arguments I am not sure it does anything. Here are some other approaches

Re: [O] lisp: scoping vars in repetitive defuns

2019-09-17 Thread Matt Price
On Tue, Sep 17, 2019 at 8:46 AM John Kitchin wrote: > I don't totally understand what you are trying to do here. > I think the explanation was a little unclear! > If this were Python, it sounds like you want some kind of class that > stores a variable and reuses it several different

Re: [O] lisp: scoping vars in repetitive defuns

2019-09-17 Thread Nick Dokos
Matt Price writes: > I have a number of convenience functions define to help me with grading > assignments. As I go through the semester, i update all of these functions > modestly so that they'rehelpful for grading the current > assignment.  > > I big chunk of these simple functions is taken

Re: [O] lisp: scoping vars in repetitive defuns

2019-09-17 Thread John Kitchin
I don't totally understand what you are trying to do here. If this were Python, it sounds like you want some kind of class that stores a variable and reuses it several different functions? Something kind of similar to that in elisp is a closure, which is like what you described. For example, here,

[O] lisp: scoping vars in repetitive defuns

2019-09-17 Thread Matt Price
I have a number of convenience functions define to help me with grading assignments. As I go through the semester, i update all of these functions modestly so that they'rehelpful for grading the current assignment. I big chunk of these simple functions is taken up just declaring variables with