Therefore I suggest we discuss the optimal name generation strategy
and change [1] to accommodate the results of the dicsussion.
On Sunday, December 23, 2012, Eugene Burmako wrote:Therefore I suggest we discuss the optimal name generation strategy
and change [1] to accommodate the results of the dicsussion.We already fail to generate unique names even in the same compilation unit (that's why I said it is "guaranteed" to be unique, emphasis on the quotes) and we stand to do worse here.For correctness to survive the ravages of the compiler, we need synthetic names to be "late bound" - the name needs identity, to experience the same transformations as the entity to which it is bound.
It needs to know what it was composed from so that composition can be deconstructed when necessary.
The name should never be a string - a string is what something else creates from the name.
This is in contrast to the current situation, where:
- the name is always a string, and never anything but a string- the name-string attempts to encode (lossily) a sequence of smaller name-strings- neither the subnames nor even the boundaries can be reliably reconstructed
Er, why then is not the name _the entity itself_? That guarantees binding.
Do all entities know what they're composed from sufficiently well so that this condition is met? If not, it seems that this information should be added.
That's fine, but you still have the collision problem on generated strings. And you have the problem of how to find out
class X {class Y {class Z {object W { // What am I called?def v = List(2,3,4).map(_ + 1) // What is the anon function called?}
}
}
}
with java (and javap and the like) if you don't do string-name-mangling as part of the generation process, at least.
Well, this is not so hard. Any quoting system can fix the issue here.
For example, suppose we allow $ in regular names but not in sequences, and make $$ our "sequence here!" symbol.
Not to dispute the theoretical validity of your suggestions, but I don't think you appreciate what you're up against in the compiler.
The essential difficulty is not one of identifying a better way, but of getting from here to there.
On Sun, Dec 23, 2012 at 10:43 AM, Rex Kerr <ich...@gmail.com> wrote:Er, why then is not the name _the entity itself_? That guarantees binding.I didn't intend my phrasing to exclude that possibility; "the name" was intended to imply a sufficiently abstract representation as to enclose the thing itself. That said, it cannot be the entity itself as things presently work because the entity itself is forgetful - names are often based on enclosing constructs, which change (destructively, even) over the course of compilation. Names also can depend on information which cannot be reconstructed, such as when symbols are cloned and have no type history from before the cloning took place.
Do all entities know what they're composed from sufficiently well so that this condition is met? If not, it seems that this information should be added.
Much of what is presently not accessible without reconstruction is as it is for performance reasons. How valid those reasons are I can't say; that this factor complicates any attempt to modify things I can say.
Well, this is not so hard. Any quoting system can fix the issue here.For example, suppose we allow $ in regular names but not in sequences, and make $$ our "sequence here!" symbol.You've already irreparably broken java reflection. I don't mean "it doesn't reflect scala semantics", I mean e.g. "calling getSimpleName throws a 'Malformed class name' exception" and so on.
I know how to quote things in theory. What is needed here is practice. The things which work have to keep working.
On Mon, Dec 24, 2012 at 3:55 PM, Paul Phillips <pa...@improving.org> wrote:You've already irreparably broken java reflection. I don't mean "it doesn't reflect scala semantics", I mean e.g. "calling getSimpleName throws a 'Malformed class name' exception" and so on.
Not really related to the specific naming issues at hand, but wouldn't adopting the JVM's recommended name mangling reduce the need for mangling in the first place and even eliminating it completely in most let's-mangle-symbolic-method-names cases?
No, mangling scheme is no longer exposed: https://github.com/scalamacros/kepler/blob/74d60036f59b4075fd18127e78c3a27592e40a71/src/reflect/scala/reflect/api/StandardNames.scala#L1
Is there a reason why ScalaCheck seems to be build against starr and not locker/quick?
It probably relates to avoid building it all the time for no good reason. For sure when push comes to shove (i.e. if scalacheck isn't going to work) it should be built against quick.
Is there a recommended way to do that?