Research platform for new language concepts and compiler technologies for Scala.

Calculating depth and descendants of tree

Can you guys help me with the algorithm to do these things? I have preorder, inorder, and postorder implemented, and I am given the hint to traverse the tree with one of these orders. I am using dotty to label (or "visit") the nodes.

Depth is the number of edges from the root to the bottom leaf, so everytime I move, I add +1 to the depth? Something like that?

No idea about the algorithm for descendants. They are asking about the number of nodes a specific node has under itself.

These are normal trees btw.

Source: (StackOverflow)

How to program in Scala to be forward-compatible with Dotty

In hist recent talk at Strange Loop Martin Odersky shed the light on his vision of Scala's future version called Dotty. I understand this is work-in-progress and it even may not flow into Scala (at least not very fast) due to many possible backward-compatibility issues. But if it happens, how should we program in Scala today to be forward-compatible with Dotty? I didn't get all the ideas from the talk so I'd like someone more profound to summarize the changes and describe how can we prepare to them.

Source: (StackOverflow)


Is there a simple way to compile an sbt project with Dotty?

Now that Dotty is apparently getting ready to compile larger projects, I wonder if there is a simple way to use it as drop-in replacement for Scalac in sbt projects? Like if I had the following build.sbt:

name := "Foo"

scalaVersion := "2.11.7"

Are there some steps I can take to swap out Scalac for Dotc here?

Source: (StackOverflow)

How to get started to contribute to Dotty [closed]

With the new Scala compiler Dotty bootstraps itself, I am really excited and want to learn more and contribute to it. I went through the project page, but still haven't got the hang of it. So how can I bootstrap myself to get hand dirty on it? Is there any process that current contributors follows to get himself on track?

Here is my progress so far:

  1. Checked out the code
  2. Got the code to compile and tests to run
  3. Got to run ./bin/dotc to compile a simple class
  4. Glanced the project issues

Now I am interested in what is a good way to familiar myself with the code base? Where can I find more documentations? And how are those issues being prioritized to pick up?

Source: (StackOverflow)

Tips on Using Bison --graph=[file] on Linux

Recently (about a month ago) I was trying to introduce new constructs to my company's in-house extension language, and struggling with a couple of reduce-reduce errors. While I eventually solved this problem, digging into the y.output file was no picnic.

As an experiment, I tried using Bison's --graph=<file> option to output a DOT file (note that our standard build uses Byacc, not Bison). As I'm on a 'turnkey' Linux box, I didn't have a Graphviz installation and could not easily install from RPMs (working on Red Hat Enterprise Linux 4). Instead, I built it from source.

As an initial experiment, I tried to run dotty with an output of Postscript. Now our internal language is your average home-grown, Turing-complete, dynamically typed scripting language, but I was unprepared for what followed. The dotty run took over four hours (2GHz dual core AMD64 box)! And when it was done, the graph that was rendered was not what I would call readable.

So, quite simply, I'm looking for advice. Are there a set of switches which would improve the outcome over the 'default' approach I took? I'm looking for experience in

  • optimizing 'render' time
  • improving readability of the graph
  • possible advice on better graphical viewers

Source: (StackOverflow)

Is there a relationship between the Scala Dotty Compiler and the Dependent Objects project by Nada Amin? [closed]

We've seen Martin Odersky announce the Dotty Compiler - a possible future compiler for Scala without all the baggage.

We've also seen Nada Amin release the Dependent Object Types Calculus (Dot Calculus) which has been implemented in Scala.

My question is: Is there a relationship between the Scala Dotty Compiler and the Dependent Objects project by Nada Amin?

Source: (StackOverflow)

Case class constructor argument type depending on the previous argument value

I am trying to do the following

trait Stateful {
  type State

case class SystemState(system: Stateful, state: system.State) // does not compile

That is, the type of statedepends on (the value of) system. That, however, is not supported:

illegal dependent method type: parameter appears in the type of another parameter in the same section or an earlier one

With function arguments, I could split the arguments into two argument lists, which is not possible with a case class constructor:

def f(system: Stateful)(state: system.State): Unit = {} // compiles

The best I can do is:

case class SystemState[S](system: Stateful { type State = S }, state: S) // compiles

but I was thinking that it should be possible without a type parameter, since in dotty, I suppose type parameters are desugared to type members.

My question then is, can this be expressed without type parameters?

In a more general context, I'm exploring to what extent type parameters can be replaced by type members, and when is it a good idea to do so.

Source: (StackOverflow)