--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-languag...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
trait HTMLCanvasElement extends HTMLElement {def getContext(contextId: String): Anydef getContext(contextId: "2d".type): CanvasRenderingContext2D}
--
@Simon: inspiration, I would say ;-)
q"$x" // Literal(Constant(42))Assuming that constant types will be represented with ConstantTypeTree(Literal(Constant(value))) .type-less notation will break liftable api in quasiquotes:
// StdLiftables.scala
implicit val liftInt: Liftable[Int] = { i => Literal(Constant(i)) }// user codeval x = 42
tq"$x" // Literal(Constant(42)) but it's not correct tree here
On Thu, Feb 13, 2014 at 08:26:28PM +0100, George Leontiev wrote:So, here are some big uses I would have for this technology.
> We (Eugene and I) have got them [mostly] working in scala (using the work
> done by Paul Phillips several years ago), and would really like to have
> some input from you. If this feature would be useful in your project, could
> you please share some use-cases/scenarios where it might help?
def getContext(contextId: "2d"): CanvasRenderingContext2D
What's Typescripts syntax for this?
def getContext(contextId: "2d"): CanvasRenderingContext2D
What's Typescripts syntax for this?
Exactly that: just the string as the type.
interface HTMLCanvasElement extends HTMLElement {
width: number;
height: number;
toDataURL(type?: string, ...args: any[]): string;
getContext(contextId: string, ...args: any[]): any;
getContext(contextId: "2d"): CanvasRenderingContext2D;
}Sébastien
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-languag...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
How are quasiquotes then going to support this syntax? Maybe we could still consider "42".type?
How are quasiquotes then going to support this syntax? Maybe we could still consider "42".type?
--
On Sunday, 11 May 2014 14:55:25 UTC+2, Miles Sabin wrote:What I would really like to have is the ability to signal to the
compiler that we would like a Singleton type to be inferred for a
literal value, without the macro-hackery that I currently need.
Specifically I would like to be able to write,
def foo[T <: Singleton](t: T): Option[T] = Some(t)
And have foo(23) yield Option[Int(23)]. This would be a genuinely
useful, conservative extension of current Scala, which could even be
regarded as a bugfix: It has a long standing open ticket at least for
the String literal case,
Yes, this would be a nice extension to the Scala type inference. However to be really useful it also has to work for expressions like 'foo(1 + 2)' (with type inferred to 'foo[3.type](3) : Option[3.type]').
/Jesper Nordenberg--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-interna...@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "scala-language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scala-language/9VEnFZImyJI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scala-languag...@googlegroups.com.
Isn't that more of a "special case"? If you write .type it's analogous to other singleton types.
> Yes, this would be a nice extension to the Scala type inference. However toAt the moment this drops out of constant folding automatically,
> be really useful it also has to work for expressions like 'foo(1 + 2)' (with
> type inferred to 'foo[3.type](3) : Option[3.type]').
scala> def sameType(s1: String)(s2: s1.type) = (s1, s2)
sameType: (s1: String)(s2: s1.type)(String, String)
scala> sameType("foo")("foo")
res0: (String, String) = (foo,foo)
scala> sameType("foo")("fo"+"o")
res1: (String, String) = (foo,foo)
scala> sameType("foo")("bar")
<console>:9: error: type mismatch;
found : String("bar")
required: String("foo")
sameType("foo")("bar")
^
I'm not actually convinced this is a good thing ... it means that
constant folding isn't type preserving.