[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: Macros vs. passing anonymous functions, argumentation

William James

12/31/2015 9:49:00 PM

Griff wrote:

> On Nov 23, 5:57 pm, Rainer Joswig <jos...@lisp.de> wrote:
> > I was just thinking about that topic and had some argumentation idea.
> > Guess that's not new, but it still could be handy if
> > your Ruby friends ask you why you need macros when Ruby
> > has blocks and Ruby can do all the cool things.
>
> Ask your Ruby friends to show you how to implement a 'for' loop in
> Ruby!

MatzLisp (Ruby):

def iter low, high, step=1
while low <= high
yield low
low += step
end
end

iter(0,8,2){|i| puts "The index is #{i}."}
The index is 0.
The index is 2.
The index is 4.
The index is 6.
The index is 8.

iter(0,2){|i| puts "The index is #{i}."}
The index is 0.
The index is 1.
The index is 2.

--
Amazon bans book. After nearly a month on the site, all traces of the book and
its 80 reviews have been removed.
http://jamesfetzer.blogspot.com/2015/11/debunking-sandy-hook-debunk...
https://www.youtube.com/watch?v=E...
2 Answers

Kaz Kylheku

12/31/2015 10:27:00 PM

0

On 2015-12-31, WJ <w_a_x_man@yahoo.com> wrote:
> Griff wrote:
>
>> On Nov 23, 5:57 pm, Rainer Joswig <jos...@lisp.de> wrote:
>> > I was just thinking about that topic and had some argumentation idea.
>> > Guess that's not new, but it still could be handy if
>> > your Ruby friends ask you why you need macros when Ruby
>> > has blocks and Ruby can do all the cool things.
>>
>> Ask your Ruby friends to show you how to implement a 'for' loop in
>> Ruby!
>
> MatzLisp (Ruby):
>
> def iter low, high, step=1
> while low <= high
> yield low

Fake generator nonsense that just invokes an implicit callback.

> low += step
> end
> end
>
> iter(0,8,2){|i| puts "The index is #{i}."}

Anonymous function just to implement a loop? Inefficient.

Also, you need to support some proper loop syntax. Ideally,
it would look like this:

for (i = 0 to 8 step 2)
puts "The index is #{i}"

or something very similar. No {|i| ...} bullshit.

Marco Antoniotti

1/1/2016 11:44:00 AM

0

On Friday, January 1, 2016 at 12:26:56 AM UTC+2, Kaz Kylheku wrote:
> On 2015-12-31, WJ <w_a_x_man@yahoo.com> wrote:
> > Griff wrote:
> >
> >> On Nov 23, 5:57 pm, Rainer Joswig <jos...@lisp.de> wrote:
> >> > I was just thinking about that topic and had some argumentation idea.
> >> > Guess that's not new, but it still could be handy if
> >> > your Ruby friends ask you why you need macros when Ruby
> >> > has blocks and Ruby can do all the cool things.
> >>
> >> Ask your Ruby friends to show you how to implement a 'for' loop in
> >> Ruby!
> >
> > MatzLisp (Ruby):
> >
> > def iter low, high, step=1
> > while low <= high
> > yield low
>
> Fake generator nonsense that just invokes an implicit callback.
>
> > low += step
> > end
> > end
> >
> > iter(0,8,2){|i| puts "The index is #{i}."}
>
> Anonymous function just to implement a loop? Inefficient.
>
> Also, you need to support some proper loop syntax. Ideally,
> it would look like this:
>
> for (i = 0 to 8 step 2)
> puts "The index is #{i}"
>
> or something very similar. No {|i| ...} bullshit.

Kaz. The actual program posted by the WJ-bot is in Whitespace. Just pass the full text to the WS compiler 3:)

Happy New Year.
--
MA