Re: ShenRuby 0.1.0

117 views
Skip to first unread message

Bruno Deferrari

unread,
Dec 31, 2012, 9:19:41 AM12/31/12
to qil...@googlegroups.com
On Mon, Dec 31, 2012 at 4:08 AM, Greg Spurrier <greg.s...@gmail.com> wrote:
> I'm pleased to announce the first release of my Ruby port of Shen: ShenRuby
> 0.1.0. It is pretty much just the REPL at this point, but it passes the Shen
> test suite, except for the "Qi interpreter - chapter 13" test case which
> fails due to stack overflow.
>
> Future releases will focus on supporting easy bi-directional interaction
> between Ruby and Shen and improving performance. The ultimate goal is making
> hybrid Ruby/Shen applications viable.
>
> If you are curious, you can find my blog post announcing the release at
> http://sourcematters.org/2012/12/30/announcing-shenruby-0-1-0.html and the
> source code is available on GitHub at
> https://github.com/gregspurrier/shen-ruby. If you have Ruby 1.9.3 installed,
> you can install ShenRuby and launch the repl with the commands:
>
> gem install shen-ruby
> srrepl
>
> To exit the REPL, execute '(quit)'.
>
> Any feedback and/or bug reports are warmly welcomed.
>
> Cheers,
> Greg
>

Excellent Greg. I'm playing with it and works very well so far. Great job! :)

Can I suggest you trap the INT signal to avoid the stack trace that is
printed when leaving the repl with Ctrl+C ?

something like:

Signal.trap("INT") { puts "Leaving..."; exit 1 }

Regarding the stack limits you mentioned before, the problem I had
with the Scheme port was that the 'do' implementation as implemented
by Shen doesn't allow the underlying implementation to optimize
tail-calls, what I did was to translate instances of

'(do <E1> <E2>)'

to

'(begin <E1> <E2>)'

in Scheme. This avoids the call to 'do' and makes <E2> be in tail
position so that the Scheme compiler can optimize it.

In the case of Ruby you can compile

'(do <E1> <E2>)'

to

'(<E1>; <E2>)'

but being that you use trampolines I don't think this will make any difference.

> --
> You received this message because you are subscribed to the Google Groups
> "Qilang" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/qilang/-/SO9rB8-g_Z4J.
> To post to this group, send email to qil...@googlegroups.com.
> To unsubscribe from this group, send email to
> qilang+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/qilang?hl=en.



--
BD

Bruno Deferrari

unread,
Dec 31, 2012, 9:39:07 AM12/31/12
to qil...@googlegroups.com
Mmmm... actually, compiling 'do' in this way worked for me when
testing this function:

(define factorial-h
0 Acc -> Acc
X Acc -> (do 1 (factorial-h (- X 1) (* X Acc))))

(define factorial
X -> (factorial-h X 1))

Without compiling do '(factorial 10000)' overflows, but after
compiling 'do' like I described it works.

I will be sending a pull-request with those changes on github soon.

>> --
>> You received this message because you are subscribed to the Google Groups
>> "Qilang" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/qilang/-/SO9rB8-g_Z4J.
>> To post to this group, send email to qil...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> qilang+un...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/qilang?hl=en.
>
>
>
> --
> BD



--
BD

Mark Tarver

unread,
Dec 31, 2012, 5:00:29 PM12/31/12
to Qilang
Congratulations! I'll be pleased to put this up.

Mark

On 31 Dec, 06:08, Greg Spurrier <greg.spurr...@gmail.com> wrote:
> I'm pleased to announce the first release of my Ruby port of Shen: ShenRuby
> 0.1.0. It is pretty much just the REPL at this point, but it passes the
> Shen test suite, except for the "Qi interpreter - chapter 13" test case
> which fails due to stack overflow.
>
> Future releases will focus on supporting easy bi-directional interaction
> between Ruby and Shen and improving performance. The ultimate goal is
> making hybrid Ruby/Shen applications viable.
>
> If you are curious, you can find my blog post announcing the release athttp://sourcematters.org/2012/12/30/announcing-shenruby-0-1-0.htmland the
> source code is available on GitHub athttps://github.com/gregspurrier/shen-ruby. If you have Ruby 1.9.3

Mark Tarver

unread,
Jan 1, 2013, 8:16:51 AM1/1/13
to Qilang
.. and it's up.

Mark
Reply all
Reply to author
Forward
0 new messages