-
Notifications
You must be signed in to change notification settings - Fork 19
Allow anonymous implicit values #9
Comments
My addendum about there being no way to refer to it subsequently is false. You can always refer to using backticks, e.g.
|
The "clever" trick of actually having a name called _ in the namespace has already shown its limits. Give the poor users a gensym. |
I'm in no way advocating it. |
It's a good point though, if we're preserving backwards compat, then we need to continue exposing |
Classic.
|
@paulp wow, what? |
I don't even want to contemplate how ALL of those examples are true. |
I'll give you a hint:
85 occurrences of the literal character sequence "name.toString". Just imagine if sometimes the name isn't in a variable called "name", or if it's |
Wow. Are there legitimate uses where you peer through the anonymity of _? I always thought/hoped it was truly totally anonymous, i.e. caused a fresh, unnamable symbol to be used or some such. (Is that what you meant by "give the poor users a gensym", paulp?) |
@gigamonkey no, it is essentially the opposite. _ is much like any other name. No, there are no legitimate uses for it, nor are there any intentional uses for it. It's just an incredibly leaky "abstraction", not that it even rises to the level of abstraction. However it's still like that because (here we go again) I tried to fix it and that was reverted, because I forgot about java. https://issues.scala-lang.org/browse/SI-6426 Yes, that's what I meant about gensym. |
See also https://issues.scala-lang.org/browse/SI-7691 for more fun with underscores. |
Hmmm. It seems like Scala could compile each _ used as a pseudo-identifier as a gensym but still allow |
@gigamonkey No, you're not missing anything. That's what it should do. With scala the difficulty is always concentrated around making the implementation do what you want. |
This is tangential, but I was going to mention that at least this is no longer true:
But instead it's become:
So I have to revisit a previous conjecture and propose unsupported pattern as the new nosymbol has no owner. |
Enable Travis CI
|
I think exposing something gensym-like is probably the safest option ... though can we call it |
Is there a Java program that uses _ as a "perfectly valid identifier" anyway? :-\ |
Someone used |
SI-6502 Convert test to asserts
Calls to synthetic case class apply methods are inlined to the underlying constructor invocation in refchecks. However, this can lead to accessibility errors if the constructor is private. This commit ensures that the constructor is at least as accessible as the apply method before performing this tranform. I've manually checked that other the optimization still works in other cases: scala> class CaseApply { Some(42) } defined class CaseApply scala> :javap -c CaseApply Compiled from "<console>" public class CaseApply { public CaseApply(); Code: 0: aload_0 1: invokespecial #9 // Method java/lang/Object."<init>":()V 4: new #11 // class scala/Some 7: dup 8: bipush 42 10: invokestatic #17 // Method scala/runtime/BoxesRunTime.boxToInteger:(I)Ljava/lang/Integer; 13: invokespecial #20 // Method scala/Some."<init>":(Ljava/lang/Object;)V 16: pop 17: return }
To resurrect this issue, please rework it as an issue/PR against Lightbend Scala (ie. scala/scala). |
Provide support for the following syntax for introducing a new implicit val without assigning a name to it.
and
Incidentally, I just realized that you can currently write:
as long as you're not at the top-level in the REPL, and you've not already bound something to _. As desired, you've got no way of referring to it by name afterwards, but it's not a solution because you only get one implicit per scope.
The text was updated successfully, but these errors were encountered: