reification

Why does Scala reify not work as according to the docs?

穿精又带淫゛_ 提交于 2019-12-11 12:06:21
问题 The Scala API docs for 2.10.3 say that I can, "Use refiy to produce the abstract syntax tree representing a given Scala expression." Accordingly, I can do: scala> val uni = scala.reflect.runtime.universe uni: scala.reflect.api.JavaUniverse = scala.reflect.runtime.JavaUniverse@4e42766 scala> uni reify { 1 to 3 } res2: uni.Expr[scala.collection.immutable.Range.Inclusive] = Expr[scala.collection.immutable.Range.Inclusive](Predef.intWrapper(1).to(3)) In the example above, I get what I am looking

type constraints and reifications regarding to joinLeft of Either

痴心易碎 提交于 2019-12-10 12:01:59
问题 joinLeft is defined as: abstract class Either[+A, +B] def joinLeft[A1 >: A, B1 >: B, C](implicit ev: A1 <:< Either[C, B1]): Either[C, B1] = this match { case Left(a) => a case Right(b) => Right(b) } With the known A and B , we need an implicit ev: A1 <:< Either[C, B1] that satisfies constraint A1 >: A, B1 >: B . reifies A1 <: Either[C, B1] For that we'll need implicit conforms[A1] and conforms[Either[C, B1]] If I'm still right until now, there seem to me many choices for A1 and B1 as long as

For Scala are there any advantages to type erasure?

北慕城南 提交于 2019-12-09 15:48:53
问题 I've been hearing a lot about different JVM languages, still in vaporware mode, that propose to implement reification somehow. I have this nagging half-remembered (or wholly imagined, don't know which) thought that somewhere I read that Scala somehow took advantage of the JVM's type erasure to do things that it wouldn't be able to do with reification. Which doesn't really make sense to me since Scala is implemented on the CLR as well as on the JVM, so if reification caused some kind of

How to check I'm inside a @specialized function or class at runtime in scala?

ぐ巨炮叔叔 提交于 2019-12-05 16:07:17
Let's say I have a specialized class and an associated companion object: trait Slice[@specialized +T] { ... override def equals(that :Any) = that match { case s :Slice[_] => ??? case _ => false } } object Slice { def newInstance[@specialized T] = ??? } Is there any way to check Inside a method of Slice if this instance is a specialized subclass, Inside a method of Slice if another instance is a specialized subclass for the same primitive, Inside a specialized method on a companion object if I'm running an erased or specialized variant without resorting to ClassTags or passing Class[_] manually

For Scala are there any advantages to type erasure?

耗尽温柔 提交于 2019-12-04 02:27:41
I've been hearing a lot about different JVM languages, still in vaporware mode, that propose to implement reification somehow. I have this nagging half-remembered (or wholly imagined, don't know which) thought that somewhere I read that Scala somehow took advantage of the JVM's type erasure to do things that it wouldn't be able to do with reification. Which doesn't really make sense to me since Scala is implemented on the CLR as well as on the JVM, so if reification caused some kind of limitation it would show up in the CLR implementation (unless Scala on the CLR is just ignoring reification).

Making statements about statements which are no reified

旧城冷巷雨未停 提交于 2019-12-03 23:00:59
问题 Forgive me if I'm misusing some terms, I'm just becoming familiar with RDF and reification in particular. What I'm trying to understand is if/how you can make a statement about a statement that you don't control and which isn't actually set up as an rdf:Statement (or any other resource, i.e., reified). For instance, if some semantic website makes the claim: ex:elvis-presley ex:is-alive "true"^^xsd:boolean . There is an implicit rdf:Statement resource here: _:x a rdf:Statement ; rdf:subject ex

Kotlin generics Array<T> results in “Cannot use T as a reified type parameter. Use a class instead” but List<T> does not

孤街醉人 提交于 2019-12-03 22:06:39
I have an interface that contains an array (or list) of T and some metadata. interface DataWithMetadata<T> { val someMetadata: Int fun getData(): Array<T> } If I write the simplest implementation of the interface, I get a compile error on the emptyArray() : "Cannot use T as a reified type parameter. Use a class instead." class ArrayWithMetadata<T>(override val someMetadata: Int): DataWithMetadata<T> { private var myData: Array<T> = emptyArray() override fun getData(): Array<T> { return myData } fun addData(moreData: Array<T>) { this.myData += moreData } } However, if I change both the

Any word on reified generics in Java?

自闭症网瘾萝莉.ら 提交于 2019-12-03 12:49:33
I know this question will probably provoke more discussion than concrete answers (which I know isn't preferable). But with the recent acquisition by Oracle, I was wondering if there's been any word that Java might (someday) get reified generics? I've heard that Oracle wants to give Java a bit of a boost, and I can think of no better way. There's a good article on the discussion of reified generics, here , that you should read in regards to Java. Basically it outlines some of the pitfalls that might happen with the introduction of such a change. It's fairly brutal for backwards compatibility

What do “reify” and “reification” mean in the context of (functional?) programming?

元气小坏坏 提交于 2019-12-02 16:03:30
I read this term a lot in blogs about haskell and functional programming (specially in sigfpe's blog ) but I don't have a clue about what it means. I get away with not knowing it most of the times, but I probably would have understood the texts a lot better if I knew. Google didn't help me. I get lost in the technical stuff. Also the non-technical meaning of the world ("turning the abstract concrete") doesn't help me understand what it practically means to reify something in code. I'm kinda slow with computer science concepts, so practical examples with code would be nice. :P Vivin Paliath So

Overloading generic event handlers in Scala

試著忘記壹切 提交于 2019-12-01 04:15:48
If I define the following generic event handler trait Handles[E <: Event] { def handle(event: E) } with event type's like this trait Event { } class InventoryItemDeactivated(val id: UUID) extends Event; class InventoryItemCreated(val id: UUID, val name: String) extends Event; how do I then make a single class that implements event handlers for each of these events ?. I tried: class InventoryListView extends Handles[InventoryItemCreated] with Handles[InventoryItemDeactivated] { def handle(event: InventoryItemCreated) = { } def handle(event: InventoryItemDeactivated) = { } } but Scala complains