From: David King Landrith Date: 2004-04-05T10:03:44+09:00 Subject: Re: Variable names > Does that help any? Immensely. Your post obviously took some time and effort to write. Thank you. On Apr 4, 2004, at 7:04 PM, Hal Fulton wrote: > David King Landrith wrote: >> After 2 days and several emails, I still have no idea how the >> characters are getting evaluated and resolved by the interpreter and >> at what point these resolved or evaluated characters are disposed of >> in favor of the objects that they represent. Moreover, I still have >> no idea if or why this question may reflect a category mistake. > > OK, let me take a stab at this. > > If I understand you correctly, you want to retrieve the original > expression on which a method was called. > > In the current Ruby implementation, this is absolutely impossible. > Ruby does not at this time expose such a deep and detailed knowledge of > the state of the interpreter's internals. > > It is true that the expression is represented as a string of > characters, > and that this eventually corresponds to an object on which you may call > a method. > > But the resolution or evaluation as you call it happens so early, so > deep in the bowels of the interpreter, that the running code cannot get > access to the original text. > > Ruby is a very introspective language. But no language (in my > repertoire) has such a deep, deep introspection -- not Java, not Ruby, > not anything else (that I know). > > Lisp is probably an exception -- in fact, I would think it would be. > And there are likewise probably others. > > The Ruby interpreter is a black box. Exposing its internals to the > running program requires a great deal of work on the part of the > language implementor. What's more, it makes sense to hide everything > that doesn't NEED to be exposed, for the sake of modularity. > > So there are only certain things that are exposed. eval(), for > instance, > is like a little window into the guts of the interpreter. But it is a > window that took man-months to get right. > > > I have no experience in writing compilers/interpreters, and I don't > > believe that I should have to in order to learn about such topics. > > If you want to solve a problem of such gigantic complexity, and there > has been no provision for this kind of thing in advance, then yes, > you do need knowledge of writing interpreters, because you will have > to write one of your own that does what you want. > > In short: The Ruby interpreter doesn't do what you want. > > Your alternatives are: > 1. Use a different language, such as Lisp. > 2. Write your own Ruby interpreter. > 3. Persuade Matz to invest a few man-months in this endeavor. > > Does that help any? > > Hal ------------------------------------------------------- David King Landrith (w) 617.227.4469x213 (h) 617.696.7133 One useless man is a disgrace, two are called a law firm, and three or more become a congress -- John Adams ------------------------------------------------------- public key available upon request