From: ·············@yahoo.es
Subject: Ruby in Lisp
Date: 
Message-ID: <1182457723.495141.69440@c77g2000hse.googlegroups.com>
 I would like to know if there is any implementation of Ruby in Lisp.

 I think that the idea of using  the dot for eliminating parenthesis
is a very
good one:

  I prefer  l.length to (length l)

  Do any of you have an automatic way of doing something like this,
that is

  First: Detect that a function has only 1 argument, then transform

  (f a)  into a.f

 Second:  Detec that f has more than one argument, transform

  (f a b) into a.f(b)  etc.

 Third.  Use multiple times this idea:

 (first (last l))  ->  l.last.first

Please, i like to have this small programm to play with it.

 Thanks to all the people in this lisp channel for a possible answer.

From: Willem Broekema
Subject: Re: Ruby in Lisp
Date: 
Message-ID: <1182485015.381851.131310@e9g2000prf.googlegroups.com>
On Jun 21, 10:28 pm, ·············@yahoo.es wrote:
>  I would like to know if there is any implementation of Ruby in Lisp.

As Python is quite similar, you may be interested in Lython, a Lisp
syntax for generating Python byte code:

 http://www.caddr.com/code/lython/ (currently down)
 http://lemonodor.com/archives/000648.html

Phil Hagelberg started working on a Ruby compiler written in Lisp, but
it seems inactive:

 http://rubyforge.org/projects/darjeeling/

My own project CLPython, a compiler for Python written in Lisp, does
not offer a nice way to write Python using s-expressions the way
Lython does. It seems not too hard to add though.

 http://common-lisp.net/project/clpython/


- Willem
From: Pascal Bourguignon
Subject: Re: Ruby in Lisp
Date: 
Message-ID: <87645hm3go.fsf@thalassa.lan.informatimago.com>
·············@yahoo.es writes:

>  I would like to know if there is any implementation of Ruby in Lisp.
>
>  I think that the idea of using  the dot for eliminating parenthesis
> is a very
> good one:
>
>   I prefer  l.length to (length l)
>
>   Do any of you have an automatic way of doing something like this,
> that is
>
>   First: Detect that a function has only 1 argument, then transform
>
>   (f a)  into a.f
>
>  Second:  Detec that f has more than one argument, transform
>
>   (f a b) into a.f(b)  etc.
>
>  Third.  Use multiple times this idea:
>
>  (first (last l))  ->  l.last.first
>
> Please, i like to have this small programm to play with it.
>
>  Thanks to all the people in this lisp channel for a possible answer.

You'd have to write a parser for your syntax and generate a sexp to be
evaluated for each expression.  You can implement this in an afternoon.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.
From: Pascal Bourguignon
Subject: Re: Ruby in Lisp
Date: 
Message-ID: <87y7idko9q.fsf@thalassa.lan.informatimago.com>
Pascal Bourguignon <···@informatimago.com> writes:

> ·············@yahoo.es writes:
>
>>  I would like to know if there is any implementation of Ruby in Lisp.
>>
>>  I think that the idea of using  the dot for eliminating parenthesis
>> is a very
>> good one:
>>
>>   I prefer  l.length to (length l)
>>
>>   Do any of you have an automatic way of doing something like this,
>> that is
>>
>>   First: Detect that a function has only 1 argument, then transform
>>
>>   (f a)  into a.f
>>
>>  Second:  Detec that f has more than one argument, transform
>>
>>   (f a b) into a.f(b)  etc.
>>
>>  Third.  Use multiple times this idea:
>>
>>  (first (last l))  ->  l.last.first
>>
>> Please, i like to have this small programm to play with it.
>>
>>  Thanks to all the people in this lisp channel for a possible answer.
>
> You'd have to write a parser for your syntax and generate a sexp to be
> evaluated for each expression.  You can implement this in an afternoon.


For example, here is a simple lisp REPL

(defmacro handling-errors (&body body)
  `(HANDLER-CASE (progn ,@body)
     (simple-condition 
         (ERR) 
       (format *error-output* "~&~A: ~%" (class-name (class-of err)))
       (apply (function format) *error-output*
              (simple-condition-format-control   err)
              (simple-condition-format-arguments err))
       (format *error-output* "~&")
       (finish-output))
     (condition 
         (ERR) 
       (format *error-output* "~&~A: ~%  ~S~%"
               (class-name (class-of err)) err)
       (finish-output))))


(defun repl ()
  (do ((+eof+ (gensym))
       (hist 1 (1+ hist)))
      (nil)
    (format t "~%~A[~D]> " (package-name *package*) hist)
    (finish-output)
    (handling-errors
     (setf - (read *standard-input* nil +eof+))
     (when (or (eq - +eof+)
               (member - '((quit)(exit)(continue)) :test (function equal)))
       (return-from repl))
     (let ((results (multiple-value-list (eval -))))
       (shiftf +++ ++ + -)
       (shiftf /// // / results)
       (shiftf *** ** * (first /)))
     (format t "~& --> ~{~S~^ ;~%     ~}~%" /)
     (finish-output))))



C/USER[25]> (repl)

COMMON-LISP-USER[1]> (defvar *a* '(1 2 3))

 --> *A*

COMMON-LISP-USER[2]> (length *a*)

 --> 3

COMMON-LISP-USER[3]> (quit)

NIL
C/USER[26]>



You can modify it to make it a ruby REPL by adding a ruby parser:


(defun parse-ruby-source (source)
  ;; Q&D stub parser.
  (if (and (null (position #\( source))
           (null (position #\) source))
           (position #\. source))
    (loop ;; parse a.b.c --> (c (b a))
       :with words = (split-sequence:split-sequence #\. source)
       :for sexp = (intern (string-upcase (pop words)))
       :then `(,(intern (string-upcase (pop words))) ,sexp)
       :while words
       :finally (return sexp))
    ;; parse the rest. Since I don't implement a full ruby parser,
    ;; I fall back to the lisp parser:
    (read-from-string source)))


(defun ruby-read (stream eof-error-p eof-value)
  (let ((ruby-source (read-line stream nil nil)))
    (if ruby-source
      (parse-ruby-source ruby-source)
      (if eof-error-p
        (error 'end-of-file :stream stream)
        eof-value))))


(defun ruby-repl ()
  (do ((+eof+ (gensym))
       (hist 1 (1+ hist)))
      (nil)
    (format t "~%~A[~D]> " (package-name *package*) hist)
    (finish-output)
    (handling-errors
     (setf - (ruby-read *standard-input* nil +eof+))
     (when (or (eq - +eof+)
               (member - '((quit)(exit)(continue)) :test (function equal)))
       (return-from ruby-repl))
     (let ((results (multiple-value-list (eval -))))
       (shiftf +++ ++ + -)
       (shiftf /// // / results)
       (shiftf *** ** * (first /)))
     (format t "~& --> ~{~S~^ ;~%     ~}~%" /)
     (finish-output))))



C/USER[10]> (RUBY-REPL)

COMMON-LISP-USER[1]> (defvar *a* '(1 2 3))
 --> *A*

COMMON-LISP-USER[2]> *a*.length.1+
 --> 4

COMMON-LISP-USER[3]> (quit)
NIL
C/USER[11]> 


Of course, you'll have to implement a full ruby parser in PARSE-RUBY-SOURCE
to be able to read more complex expressions. 

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.
From: Pascal Bourguignon
Subject: Re: Ruby in Lisp
Date: 
Message-ID: <87sl8klu1e.fsf@thalassa.lan.informatimago.com>
Vagif Verdi <···········@gmail.com> writes:

> Dude, if you want Ruby, there's only one advise for you: Run from this
> place as far as you can.
> The guardians are coming any minute.

Let him implement a ruby parser in Lisp.  Once he's done, he may have
become a lisp programmer and see the light! :-)

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.
From: fireblade
Subject: Re: Ruby in Lisp
Date: 
Message-ID: <1182500446.441822.84990@w5g2000hsg.googlegroups.com>
Vagif Verdi <···········@gmail.com> writes:
> > Dude, if you want Ruby, there's only one advise for you: Run from this
> > place as far as you can.
> > The guardians are coming any minute.
>

Social problems of lisp?  Lispers are monsters that will torn you
apart and feed the pirannas.
Or rather  "A lie repeated a hundred times becomes the truth." -
Chairman Mao

People of this group will treat you nice if you play nice on your
side, no trolling nor whining. Everybody has a right to have an
opinion and people respect that, the poster should respect that too.
Badvertisers, crybabies and lazies are dealt with the way they
deserve.

Slobodan Blazeski

My apologies to those who like Java, C#, PHP, Delphi, Visual Basic,
Perl, Python, Ruby, COBOL, F#, Ocaml or any other language. I know you
think you  know a better language than lisp. All I can say is I do,
too!
From: Alex Mizrahi
Subject: Re: Ruby in Lisp
Date: 
Message-ID: <467bb8a3$0$90276$14726298@news.sunsite.dk>
(message (Hello 'fireblade)
(you :wrote  :on '(Fri, 22 Jun 2007 08:20:46 -0000))
(

 f> Social problems of lisp?  Lispers are monsters that will torn you
 f> apart and feed the pirannas.

have you been in comp.lang.c++ newsgroup? everything that is not about the 
standard C++ is declared offtopic there -- if you ask such question, you'll 
get response "it's offtopic here, go away, into a Microsoft newsgroup", or 
something like this.. ye, i know, there's just too much C++ programmers, so 
if they won't have strict rules, it will be flooded to death..

but anyway.. i once was asking a question about C++ language, but i've 
mentioned using a MFC CString class (it could be any class with same 
operator signatures as well, i just appealed to a CString example). and 
certainly they've sent me away, into a msft newsgroup (and i went there, but 
got no reply). then i rephrased my question in pure standard C++ terms, but 
again got no reply..
i've only got explanation when i've showed question to my friend, a C++ 
guru. this was a quite advanced _standard_ behaviour complication, that have 
lead to annoying consequences (basically, you are not able to output CString 
(or wrapper class like that) it into wostream without explicit type 
conversion).

 f> People of this group will treat you nice if you play nice on your
 f> side, no trolling nor whining.

so actually comp.lang.lisp is a very friendly newsgroup, comparing to 
others.. i don't see any "social problems", perhaps lispers just have 
strange sense of humour and have enough time to speak about things other 
than standard ANSI Common Lisp..

)
(With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
"I am everything you want and I am everything you need") 
From: fireblade
Subject: Re: Ruby in Lisp
Date: 
Message-ID: <1182515082.086478.169440@o61g2000hsh.googlegroups.com>
On Jun 22, 1:55 pm, "Alex Mizrahi" <········@users.sourceforge.net>
wrote:
> (message (Hello 'fireblade)
> (you :wrote  :on '(Fri, 22 Jun 2007 08:20:46 -0000))
> (
>
>  f> Social problems of lisp?  Lispers are monsters that will torn you
>  f> apart and feed the pirannas.
>
> have you been in comp.lang.c++ newsgroup? everything that is not about the
> standard C++ is declared offtopic there -- if you ask such question, you'll
> get response "it's offtopic here, go away, into a Microsoft newsgroup", or
> something like this.. ye, i know, there's just too much C++ programmers, so
> if they won't have strict rules, it will be flooded to death..
>
> but anyway.. i once was asking a question about C++ language, but i've
> mentioned using a MFC CString class (it could be any class with same
> operator signatures as well, i just appealed to a CString example). and
> certainly they've sent me away, into a msft newsgroup (and i went there, but
> got no reply). then i rephrased my question in pure standard C++ terms, but
> again got no reply..
> i've only got explanation when i've showed question to my friend, a C++
> guru. this was a quite advanced _standard_ behaviour complication, that have
> lead to annoying consequences (basically, you are not able to output CString
> (or wrapper class like that) it into wostream without explicit type
> conversion).
>
>  f> People of this group will treat you nice if you play nice on your
>  f> side, no trolling nor whining.
>
> so actually comp.lang.lisp is a very friendly newsgroup, comparing to
> others.. i don't see any "social problems", perhaps lispers just have
> strange sense of humour and have enough time to speak about things other
> than standard ANSI Common Lisp..
>
> )
> (With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
> "I am everything you want and I am everything you need")

I agree with everything you said, but it's not me who claims that cll
has social problems . It's exactly the opposite.

Slobodan Blazeski
From: Vagif Verdi
Subject: Re: Ruby in Lisp
Date: 
Message-ID: <1182550349.426890.230270@d30g2000prg.googlegroups.com>
>People of this group will treat you nice if you play nice on your
side, no trolling nor whining.

Excuse me, but requesting dot notation in lisp IS trolling :))
From: fireblade
Subject: Re: Ruby in Lisp
Date: 
Message-ID: <1182499736.472796.306400@q75g2000hsh.googlegroups.com>
On Jun 21, 10:28 pm, ·············@yahoo.es wrote:
>  I would like to know if there is any implementation of Ruby in Lisp.
>
>  I think that the idea of using  the dot for eliminating parenthesis
> is a very good one:
>
>   I prefer  l.length to (length l)

No it's not, it makes syntax more complicated with many more rules and
even more exceptions. Lisp syntax is very simple one with one rule &
couple of exceptions, showing teh  beauty of orthogonal language and
it's power. Forgeth for a 2 weeks about dot and use s-expessions all
the time.Afterward return  to dot. If you don't sense the impurity of
the notation maybe lisp is not for you, at least at this time. I like
using dot with C++/C# with my VS intellisense but I see it as just
another  low hack helping grasp to poorly designed language.  Lisp is
different.  At Java/C#/C++ functions(methods) belong to objects making
dot acceptable, but with limitation that method is part of the class,
lisp OO started this way but limitation were seen quckly.Modern Lisp
OO system (The CLOS) is more powerfull than that . Methods belong to
Generic functions and they could specialize on different type of
objects. Also there would be problem with making writing macros too
hard that they would be rarely used.
My advice is taht when you learn new language it's might be better to
try to learn it's  spirit ,instead of programming old language in the
new one. When I use C# I mean OO, with Transact-SQL queries and stored
procedures, Erlang comes with concurrency, C++ is trickier but full of
pointers & structs, with lisp making your own languages and buttom up
programming.Read the preface & chapter 1 of On Lisp freely available
at http://www.paulgraham.com/onlisp.html. Graham writes far better
than I do.



Slobodan Blazeski

My apologies to those who like Java, C#, PHP, Delphi, Visual Basic,
Perl, Python, Ruby, COBOL, F#, Ocaml or any other language. I know you
think you  know a better language than lisp. All I can say is I do,
too!
From: Pascal Bourguignon
Subject: Re: Ruby in Lisp
Date: 
Message-ID: <873b0kl7nw.fsf@thalassa.lan.informatimago.com>
fireblade <·················@gmail.com> writes:

> On Jun 21, 10:28 pm, ·············@yahoo.es wrote:
>>  I would like to know if there is any implementation of Ruby in Lisp.
>>
>>  I think that the idea of using  the dot for eliminating parenthesis
>> is a very good one:
>>
>>   I prefer  l.length to (length l)
>
> No it's not, 

No use to say it.  Colors and tastes...
Let the newbie implement it in lisp and see the light by himself!


> it makes syntax more complicated with many more rules and
> even more exceptions. [...]

Of course.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.
From: Kjetil S. Matheussen
Subject: Re: Ruby in Lisp
Date: 
Message-ID: <Pine.LNX.4.64.0706221354150.9731@ttleush>
On Thu, 21 Jun 2007, ·············@yahoo.es wrote:

>
> I would like to know if there is any implementation of Ruby in Lisp.
>
> I think that the idea of using  the dot for eliminating parenthesis
> is a very
> good one:
>
>  I prefer  l.length to (length l)
>

Its not very difficult (you even can implement it only using 
syntax-case macros in many schemes, as was recently shown on 
comp.lang.scheme), but IMHO a much better alternative is:

(defmacro -> (object method &rest arguments)
   `(,method ,object ,@arguments))

(defvar a '(1 2 3 4 ))

(-> l length)
=> 4


Its more verbose, but the -> symbol is faster to spot in large 
code blocks.


Well, whatever you do, have fun with lisp. :-)