Quantcast
Channel: User Alec - Stack Overflow
Browsing index pages (44 articles)

Answer by Alec for Add sources for unmanaged JARs in SBT

Posting what I ended up actually doing in case it is useful for others...My interest in source JARs was in order to have the SBT BSP do the right thing for jumping to definitions of unmanaged JARs. I...

View Article


Given two absolute paths, how can I express one of the paths relative to the...

I think this should be quite doable, given that there is a nice function canonicalize which normalizes paths (so I can start by normalizing my two input paths) and Path and PathBuf give us a way of...

View Article


Comment by Alec on Add sources for unmanaged JARs in SBT

Un-jarring will have other jarring (haha) consequences though. It means that jumping to definition will not longer bring people into a JAR, it'll just be a source file (this is an annoyance I'd be...

View Article

Comment by Alec on Add sources for unmanaged JARs in SBT

@GaëlJ yeah, I want to provide the sources in the IDE (eg. goto-definition). I'm using Metals, but tracing through both the integration through Bloop and SBT directly, things come back to...

View Article

Comment by Alec on Python: can generators be recursive?

@Yuta73 yes, it is

View Article


Lifetime of arena in long-running web server

I'm working on a compiler pipeline and am not sure how to properly model ownership of ASTs with arenas.I have types inside the AST represented as references into arenas (quite like rustc's own TyCtxt),...

View Article

Future of roles for GADT-like type variables?

A question from yesterday had a definition of HList (from the HList package) that uses data families. Basically:data family HList (l :: [*])data instance HList '[] = HNilnewtype instance HList (x ':...

View Article

Cross-building Scala libraries

I would like to cross-build some of my Bazel targets to Scala 2.12 and 2.13. As a further point of complexity, I need to be able to express cross-target dependencies (eg. some 2.13 target may have a...

View Article


Answer by Alec for How to bring type information into value level in Haskell?

It boils down to finding what you want to do with that type information. In either case, the modules you will probably be looking at are Data.Typeable and Data.Data. At the center of these modules are...

View Article


Finding the second matching implicit

Consider the following setup:trait Foo[A]object Foo extends Priority2trait Priority0 { implicit def foo1: Foo[Int] = new Foo[Int] {}}trait Priority1 extends Priority0 { implicit def foo2: Foo[Boolean]...

View Article

Image may be NSFW.
Clik here to view.

Table class for tables that, when too wide split all their cells into rows

I am trying to figure out what HTML / CSS I need to get a certain breaking behavior depending on how much space is available. Basically, I want to have a long line of text automatically break at...

View Article

Answer by Alec for Does java support and optimize away tail-recursive calls?

Java and the JVM do not currently support tail callsThe fundamental work that needs to happen is at the level of the JVM, not Java. There has been a slow moving line of work to address this (initially...

View Article

Answer by Alec for Why are Scala's LazyList's elements displayed as...

Instead of using LazyList.apply, any of the following work (without evaluating their arguments):LazyList.tabulate(3)(fun)fun(1) #:: fun(2) #:: fun(3) #:: LazyList.emptyLazyList.range(1, 4).map(fun)Why...

View Article


Idiomatic way to turn an owned value into a reference with arbitrary lifetime

Consider the following typepub struct Foo<'a> { bar: &'a str,}If I try making a constructor for this type using a String, I'll run into errors about bar not living long enough:impl<'a>...

View Article

Is `BoundedSourceQueue` from `Source.queue` ok with concurrent producers?

Source.queue recently added an overload which specializes to OverflowStrategy.dropNew and avoids the async mechanism. The result of materializing this is a BoundedSourceQueue[T] (compared to...

View Article


How to mimic `tableswitch` using `MethodHandle`?

Context: I've been benchmarking the difference between using invokedynamic and manually generating bytecode (this is in the context of deciding whether a compiler targeting the JVM should emit more...

View Article

JVM optimizations for `PermittedSubclasses`

Sealed classes/interfaces were added to Java with JEP 360. The JVM-level change was to add a PermittedSubclasses attribute to class files, which can be used to explicitly list out which classes are...

View Article


Answer by Alec for Maximum number of local variables in a Java Method

I'm surprised by the lack of straight answer to this clear question, so here goes: the JVM has a max frame size of 65535 locals and max stack size of 65535, with long and double consuming 2 slots per...

View Article

Why does a reference in the JVM not take two stack slots [duplicate]

Looking at the JVM 15 specification (first two sections here), I see thatreference, int, and float take only one local variable slot and one stack slotlong and double, take 2 slotsEverything in the...

View Article

How to do a `getOrElseComplete` on `Promise`?

Does it make sense to have an operation like getOrElseComplete that tries to complete a Promise with a value but, if the Promise is already completed, returns the existing completed value instead....

View Article
Browsing index pages (44 articles)


Latest Images