You're quite correct that the namespace \mechanism as it stands would not work for this----good point. I guess I am just suggesting using the \syntax to do something let-like. Perhaps it would be better to make up a completely different syntax.
As for your example, I'm still not sure we understand each other: (let [x (foo 17), dx foo/double-x] (do-something-with x dx)) Yes, that is how it would \look (I've dropped the user. as it isn't needed here). But why is the \name user.foo/double-x changing? It is dictated in the definition of foo, which is not itself changing. And (keeping in mind what I said above) once you refer to the \value in this way, it does not change. Later uses of foo should indeed \shadow this usage, not \change it. At any rate, it would be better to describe these as names within a function execution's \scope, not a function \namespace. Hopefully that is less confusing. As for storing values: as I said they should be \function-local, so that in (defn bar [...] (foo ...) (+ foo/double-x ...) ) foo/double-x expires after bar returns. On Jan 3, 2:15 pm, Tassilo Horn <tass...@member.fsf.org> wrote: > nchurch <nchubr...@gmail.com> writes: > > Replying to Tassilo: I'm not quite sure I understand this problem: > > >> then changing its name requires changing all places where > >> clojure.core.quotient/remainder is used > > > surely the call to Values takes place inside the function definition, > > which happens \once. If you want a different variable name on \use, > > you use a let; if you want to return a different variable name on > > \definition, you use a let inside the function (or perhaps Values > > could have some sugar for renaming variables). > > I understand your proposal in such a way, that in a function > > (defn foo [x] > (let [double-x (* 2 x)] > (values x double-x))) > > the `values' was actually a macro that > > 1. creates a namespace for the function (user.foo) > > 2. creates a var holding the last second value (user.foo/double-x) > where the name of the var is dictated by the local var holding the > value > > 3. expands into code that sets user.foo/double-x at runtime and then > returns the first value x > > Then, if I want to use the second value returned by foo in my code, I'd > so something like > > (let [x (foo 17), dx user.foo/double-x] > (do-something-with x dx)) > > Since I have to refer to user.foo/double-x to get the second value, once > that name changes, I have to change my code, too. > > But probably, I've simply misunderstood your intent. > > > It's true that quotient/remainder must be thread-local (in fact it > > should really be function-local), but this makes it no different than > > a let-variable or a function parameter; it doesn't necessarily mean it > > is mutable. Is X mutable in > > > (let [X 1 > > X (inc X)]) > > > ? > > Nope, the latter X shadows the former X. But there's no such thing for > vars in a namespace. > > > If you slapped that X in a data structure, you would not find it > > changing under your nose. quotient/remainder really has to behave in > > the same way----imagine the quotient call creates an invisible let > > every time. > > Sorry, I don't get you. What am I misinterpreting in your approach? To > me, it looks like you want to bind the multiple values to vars in an > ad-hoc namespace corresponding to a function. Then, there's no such > thing as a lexical scope provided by let. A namespace is a globally > accessible thingy. > > > Perhaps I should explain why I think this is "simple". It's simple > > because a) it allows you to ignore the extra values unless you want > > them and > > Well, the Common Lisp approach does so, too. > > > b) it gives you ready-to-use names. To my taste, b) is very > > important. > > To me, that's a major downside. > > > (quotient 5 2) > > (quotient 8 3) > > > quotient(5 2)/remainder --> 1 > > Huh, you want to create a namespace not only for each function but for > each function call? And then store the multiple values for each of > them? > > Bye, > Tassilo -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en