Topics

Stanza Updates?

Yves Cloutier
 

Hi Patrick,

I'll bet a few of us keep coming to the website to see what'sthe latest happenings going on with stanza.  Would it be possible to give a little update on how things are progressing?


On another note, I'm taking a nice course on Coursera which covers ML, Racket and Ruby. I've been having some fun and trying to reproduce my homework answers in Stanza. Here's an example:

ML Version
(* Functon that takes a list of dates and a month. It returns the number of times the month specified occurs in the list of dates*)
fun number_in_month(dates: (int*int*int) list, month:int) =
  if null dates (*edge case*)
  then 0
  else
    if #2(hd(dates)) = month
    then 1 + number_in_month(tl dates, month)
    else 0 + number_in_month(tl dates, month)

Stanza Version

defstruct Date :
  year:Int
  month:Int
  day:Int

defn number-in-month (dates:List<Date>, selected-month:Int) -> Int:
  if empty?(dates) :
    0
  else :
    if month(head(dates)) == selected-month :
       1 + number-in-month(tail(dates), selected-month)
    else :
       0 + number-in-month(tail(dates), selected-month)

I wasn't sure how to specify an argument of type "list of tuples" as in the ML version, so instead I ended up creating a struct and having the type be a List<Date>.

A simple example, I know, but still...fun:)


 

Hi Yves.

There are some exciting updates coming out this week actually. The Stanza separate compiler is done and allows for packages to be independently and separately compiled. This reduces compilation times by allowing you to recompile only the packages that have changed. This was a crucial piece of functionality to enable Stanza to be used for large projects.

Thanks for posting your homework solution. Your code is very clean! 

I, myself, prefer your solution of using a separate Date struct, but should the need arise in the future, you can specify a list of tuples as "List<[Int, Int, Int]>".


Merry Christmas!

  -Patrick

Yves Cloutier
 

Great! Thanks for the update Patrick. Will look out for a new version in the next couple weeks!


For the homework I was trying to keep it as close to the ML version as possible, but I agree having a struct and being able to to something like month(head(dates)) reads much better.


 

Hey Patrick,

I was wondering if you could post a blurb about the recent commits on github. Perhaps even adding it to the news page would be good to show more signs of life.

Thanks for your time!

Jake

 

Hi Jake!

Thanks for noticing! It's the result of me doing a fairly major restructuring of the mid-end to allow for more aggressive inlining optimizations. It's still tagged as an experimental release until we stress-test it and make sure there weren't any new bugs introduced. I'll make a news update on the website soon.

  -Patrick