the perens in lisp dilects is there for a reson... macros.

A

atbusbook

macros are sort of like c macros but more powerful. they are the
manafestation of treating code like data. lisp code is just a textual
representation of a data structure that is the list. this means that
you can manipulate code to emulate structured controll constructs and
elemanate boilerplate code. to show you the power of a macro heer is a
while loop

<code>
(defmacro while (test &body body)
`(do ()
((not ,test))
,@body)
</code>

Another one would be untill

<code>
(defmacro untill (test &body body)
`(while (not ,test) ,@body))
</code>

wich is defined on top of while

another test to wead out programers would be lisp stile macros because
of variable capture
and other perls of the macro world. but higenic macros can not have the
power of true macros

i also hear you talk about introspection. in lisp you use eval list

lets define a sum function to show you

<code>
(defun sum (lst)
(eval (append '(+) lst)))
</code>

another example would be this

<code>
(loop (print (eval (read))))
</code>
this is an interactive top level in 1 line

another use is for calling of functions

<code>
(defvar cmds `('foo ,(lambda () (format t "hello world")))
(funcall (getf cmds (read-from-string (read-line))))
</code>
of corse no error checking for comas and other things that could crash
the program
 
C

Chad Perrin

The parentheses are not strictly necessary for macros. They're just the
traditional LIspy way to do it. For instance, this is from UCBLogo's
help documentation (I copied the first screenful from a terminal
emulator):



MACRO procname :input1 :input2 ... (special form)
DEFMACRO procname text

A macro is a special kind of procedure whose output is evaluated
as Logo instructions in the context of the macro's caller.
.MACRO is exactly like TO except that the new procedure becomes
a macro; .DEFMACRO is exactly like DEFINE with the same exception.

Macros are useful for inventing new control structures comparable
to REPEAT, IF, and so on. Such control structures can almost, but
not quite, be duplicated by ordinary Logo procedures. For example,
here is an ordinary procedure version of REPEAT:

to my.repeat :num :instructions
if :num=0 [stop]
run :instructions
my.repeat :num-1 :instructions
end

This version works fine for most purposes, e.g.,

my.repeat 5 [print "hello]

But it doesn't work if the instructions to be carried out include
OUTPUT, STOP, or LOCAL. For example, consider this procedure:

to example
print [Guess my secret word. You get three guesses.]
repeat 3 [type "|?? | ~
if readword = "secret [pr "Right! stop]]
print [Sorry, the word was "secret"!]
end

This procedure works as written, but if MY.REPEAT is used instead
of REPEAT, it won't work because the STOP will stop MY.REPEAT
instead of stopping EXAMPLE as desired.

The solution is to make MY.REPEAT a macro. Instead of actually
carrying out the computation, a macro must return a list containing
Logo instructions. The contents of that list are evaluated as if
they appeared in place of the call to the macro. Here's a macro
version of REPEAT:
 
D

Daniel Martin

<smug lisp weenie giving standard lisp macro rant omitted>

This appears to be the continuation of some conversation / flamewar
somewhere else. Why bring this crud over here? Is there some reason
that we should care?

Fine, lisp macros are great and glorious and the be all and end all of
programming constructs, and all other languages hopelessly inferior.
All hail lisp macros. They're even so great and wonderful we'll bow
down before the wisdom of someone who manages to cram three spelling
errors and an awful grammar error into the subject line. You've
proven your vast superiority over us with your l33t lisping skillz.

Can you just go away now and let us get back to ruby?
 
R

Rick DeNatale

This appears to be the continuation of some conversation / flamewar
somewhere else. Why bring this crud over here? Is there some reason
that we should care?

I've only recently subscribed to this list, after just sampling it for
a while, and I've been wondering the same thing about the apparently
endless discussion of the merits of C, C++, Ocaml, and Java
 
C

Charles Hoffman

I've only recently subscribed to this list, after just sampling it for
a while, and I've been wondering the same thing about the apparently
endless discussion of the merits of C, C++, Ocaml, and Java

That stuff doesn't bother me, it seems normal for users, enthusiasts,
and people interested in one programming language to talk about other
programming languages. Programmers these days usually have to use
multiple languages in their work anyway, and may have some functionaliy
written in another language that they need to interface with Ruby. It's
less fun to have a topic-nazi policy.

I've also noticed that Rubyists seem have a high tendency (at least
higher than Javaists and others, I think) to be programming-language
geeks, the kind of folks who like to learn about the general concepts of
programming languages, learn lots of different ones, and compare them.
I'd count myself more among those than a Rubyist at this point, as I've
yet to work on a real project in Ruby yet (but I'm itching to).

--ch--
 
C

Charles Hoffman

Oh, and if anyone's keeping score, the parens in Lisp/Scheme are there
to structure the code and data. Where other languages are full of {},
[], ;, and all sort of other punctuation marks, in Lisp you only
have/need parentheses to serve all the same purposes. It doesn't have
anything to do with macros per se.

--ch--
 
M

M. Edward (Ed) Borasky

Rick said:
I've only recently subscribed to this list, after just sampling it for
a while, and I've been wondering the same thing about the apparently
endless discussion of the merits of C, C++, Ocaml, and Java
Whatever you opinions about any programming language are, Ruby is
implemented in C at the moment, so C at least has *that* going for it! :) :)
 
M

M. Edward (Ed) Borasky

Charles said:
That stuff doesn't bother me, it seems normal for users, enthusiasts,
and people interested in one programming language to talk about other
programming languages.
Especially the denizens of the main Ruby mailing list, which includes
the founder of the language. We are people who use or want to use Ruby,
and we want it to have what it needs from other languages. Matz did a
pretty good job of that all by himself. :)

Programmers these days usually have to use
multiple languages in their work anyway,
Well ... my personal opinion is that more than two languages is probably
overload. You need one general purpose language and whatever
domain-specific language fits what you're doing. More than that and you
start losing time context switching and spending time looking up things
like "how do I parse a date/time string to a date/time object in Ruby
when I know how to do it in R?" :)
I've also noticed that Rubyists seem have a high tendency (at least
higher than Javaists and others, I think) to be programming-language
geeks, the kind of folks who like to learn about the general concepts of
programming languages, learn lots of different ones, and compare them.
That may be because of Ruby's youth relative to other general-purpose
languages. I remember the same phenomenon when Java was a young
language. I'm personally a language geek and have been since ... well,
let's just say that the first code I wrote in my life was for a machine
built from vacuum tubes that had only an assembler. :)
 
D

dblack

Hi --

Especially the denizens of the main Ruby mailing list, which includes the
founder of the language. We are people who use or want to use Ruby, and we
want it to have what it needs from other languages. Matz did a pretty good
job of that all by himself. :)


Well ... my personal opinion is that more than two languages is probably
overload. You need one general purpose language and whatever domain-specific
language fits what you're doing. More than that and you start losing time
context switching and spending time looking up things like "how do I parse a
date/time string to a date/time object in Ruby when I know how to do it in
R?" :)

That may be because of Ruby's youth relative to other general-purpose
languages. I remember the same phenomenon when Java was a young language.

I think Ruby is slightly older than Java, isn't it? :)
I'm personally a language geek and have been since ... well, let's
just say that the first code I wrote in my life was for a machine
built from vacuum tubes that had only an assembler. :)

You may have me beat. My first was BASIC on a PDP-8, followed by
BASIC and assembler on a PDP-10. I think at least the '10 had
integrated circuits :)

As for language geekdom: I feel like I used to be more than I am now,
but it's more because Ruby stuff is keeping me so busy than because
Ruby satisfies all my language interest. In fact I've never wanted
Ruby to take on Lisp macros, Python whitespace, Java-style typing,
C-style comments, and all the rest of it. Maybe there should be one
or more kitchen-sink languages out there, but they should be written
from scratch for that purpose.

Here's what I think is a classic and still very relevant post by Dave
Thomas about the design of Ruby and the process of change:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/12606


David

--
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <-----
http://dablog.rubypal.com => D[avid ]A[. ]B[lack's][ Web]log
http://www.manning.com/black => book, Ruby for Rails
http://www.rubycentral.org => Ruby Central, Inc.
 
M

M. Edward (Ed) Borasky

Charles said:
Oh, and if anyone's keeping score, the parens in Lisp/Scheme are there
to structure the code and data. Where other languages are full of {},
[], ;, and all sort of other punctuation marks, in Lisp you only
have/need parentheses to serve all the same purposes. It doesn't have
anything to do with macros per se.

--ch--
There's a bit more to it than that. Ironically, Lisp originated as an
implementation of "parenthesis-free (Polish) prefix" notation in
symbolic logic. That is, rather than write "A + (B * C)" one writes "+ A
* B C". The parentheses came about for a number of reasons:

1. Unlike my example, Lisp functions even in Lisp 1 did not have a fixed
arity,
2. As someone already pointed out, S expressions used them,
3. It's more natural when you have multi-character atoms,

etc. So in Lisp you end up with "(PLUS A (TIMES A B))".

The reverse Polish form "B C * A +" is what the early compilers
generated, and is now known as Forth. :)

Incidentally, the original Lisp spec had list elements separated by
commas, for example "(ALPHA,(BETA,GAMMA))". There was a bug/feature in
the first implementation that allowed spaces, and the rest is history. :)
 
M

M. Edward (Ed) Borasky

I think Ruby is slightly older than Java, isn't it? :)
Maybe ... Java is 1.5 and Ruby is 1.8.5, so by that measure, yes. I
suppose I need to look up the history of Ruby. But I remember jumping on
Java in the 1.1 days many years ago as a language I thought was *vastly*
superior to Perl 4, and taking flames for saying so. The Perlists had
their revenge though; I wrote one program in Java and that was it.
You may have me beat. My first was BASIC on a PDP-8, followed by
BASIC and assembler on a PDP-10. I think at least the '10 had
integrated circuits :)
I once had a boss who claimed to have worked on an IBM 1620. I think he
was trying to impress us as being a "real programmer just like us." The
lab where I worked on a 1620 got rid of it in 1964 ... I'm guessing he
was in junior high school then. :)
As for language geekdom: I feel like I used to be more than I am now,
but it's more because Ruby stuff is keeping me so busy than because
Ruby satisfies all my language interest. In fact I've never wanted
Ruby to take on Lisp macros, Python whitespace, Java-style typing,
C-style comments, and all the rest of it. Maybe there should be one
or more kitchen-sink languages out there, but they should be written
from scratch for that purpose.
A long time ago some computer scientist defined two types of languages
-- "core" languages and "shell" languages. Lisp, Scheme and Forth are
great examples of core languages ... just a few simple core concepts
from which you can build mighty software. And the classic shell
languages are PL/I and Ada ... just about anything you'd ever want to do
is built into the language.

The languages most of us use these days are in between. The core is
bigger than the core of Lisp or Forth -- it includes strings, various
floating point numbers and math functions, arrays and usually hashes,
and usually objects, classes of objects and methods. What Ruby has that
many of them lack, however, is more or less explicit use of classical
computer science concepts, usch as lambda and continuations.
 
C

Charles Hoffman

Whatever you opinions about any programming language are, Ruby is
implemented in C at the moment, so C at least has *that* going for it! :) :)

Java's VM is written in C too, is it not?

MTASC, a rather good open-source ActionScript compiler, is written in
OCaml... as is haXe, I think.

C is kind of an obvious choice for interpreters/compilers because of the
availability of Lex and Yacc (and/or flex and Bison), I suppose.

Hmmm... I had rather thought that functional-style languages were more
common for writing language interpreters/compilers in. Aren't Lisp guys
always on about using Lisp to write another language more specific to
the problem domain, and working from there?

In the Programming Languages course I took at UNI we developed an
interpreter for a simple language in Scheme... the professor I took that
course with just e-mailed me a Joy interpreter he wrote, also in Scheme,
that I had expressed interest in. In another course I took with another
prof, we used a Mumps compiler he had written in C++; actually it
translated Mumps to C++ and compiled that with gcc.

I think gForth is written in C, but there are faster Forth environments
out there; I wonder what they used. I'm pretty sure a lot of Forth
environments are started in assembler.

Anyway I'm rambling, just because this is a fun topic.

I'd learned that it was common to develop a minimal subset of a new
language in another language, then use that small version of the
language to write the rest. The Lisp environments I've used certainly
appear to have been implemented in this way, and Forth is explicitly so.
There definitely seem to be some very low-level functions in Ruby that
seem to be mainly used by more advanced Rubyists, usually for
metaprogramming-like things. Stuff like instance_eval. Am I on-track
in having the impression that Ruby is designed that way? Just curious.

--ch--
 
D

dblack

Hi --

Maybe ... Java is 1.5 and Ruby is 1.8.5, so by that measure, yes.

No, I meant older as in... older :) Ruby's birthday is traditionally
February 1994 (I can't remember the exact day), and I seem to remember
that that predates Java, but I'm not sure.


David

--
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <-----
http://dablog.rubypal.com => D[avid ]A[. ]B[lack's][ Web]log
http://www.manning.com/black => book, Ruby for Rails
http://www.rubycentral.org => Ruby Central, Inc.
 
M

M. Edward (Ed) Borasky

Hi --



No, I meant older as in... older :) Ruby's birthday is traditionally
February 1994 (I can't remember the exact day), and I seem to remember
that that predates Java, but I'm not sure.
Where can one find "a brief history of Ruby?" I'm too lazy to ask
Google, especially when Matz is on the list. :)

For that matter, how did *Google* get its name, and does it have
anything to do with Barney Google? :)
 
O

Ola Bini

M. Edward (Ed) Borasky said:
(e-mail address removed) wrote:
For that matter, how did *Google* get its name, and does it have
anything to do with Barney Google? :)

Google comes from the name of the number 10^100 which is called a
googol. Ackording to wikipedia Google originally was a misspelling of this.


--
Ola Bini (http://ola-bini.blogspot.com)
JvYAML, RbYAML, JRuby and Jatha contributor
System Developer, Karolinska Institutet (http://www.ki.se)
OLogix Consulting (http://www.ologix.com)

"Yields falsehood when quined" yields falsehood when quined.
 
D

dblack

Hi --

Where can one find "a brief history of Ruby?" I'm too lazy to ask Google,
especially when Matz is on the list. :)

Whoops, I was wrong; it was 1993. See
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/382


David

--
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <-----
http://dablog.rubypal.com => D[avid ]A[. ]B[lack's][ Web]log
http://www.manning.com/black => book, Ruby for Rails
http://www.rubycentral.org => Ruby Central, Inc.
 
O

Ola Bini

Kristof said:
On Mon, 07 Aug 2006 01:51:08 +0900, M. Edward (Ed) Borasky wrote:

Lisp is definitely not a core language. The standard is about 1100 pages,
so it contains most of of the stuff you would expect, string handling,

You seem to confuse the language Common Lisp with the mathematical
concept Lisp. Lisp is seven operators and a one-page denotional semantic
definition. That's about as small and core as it gets.

--
Ola Bini (http://ola-bini.blogspot.com)
JvYAML, RbYAML, JRuby and Jatha contributor
System Developer, Karolinska Institutet (http://www.ki.se)
OLogix Consulting (http://www.ologix.com)

"Yields falsehood when quined" yields falsehood when quined.
 
K

Kristof Bastiaensen

<snipped>
A long time ago some computer scientist defined two types of languages
-- "core" languages and "shell" languages. Lisp, Scheme and Forth are
great examples of core languages ... just a few simple core concepts
from which you can build mighty software. And the classic shell
languages are PL/I and Ada ... just about anything you'd ever want to do
is built into the language.

Lisp is definitely not a core language. The standard is about 1100 pages,
so it contains most of of the stuff you would expect, string handling,
arrays, hashes, math functions, etc... Scheme is probably more what you
would call a core language. There are documents (SRFI's) that describe
common implementations for libraries, but scheme implementations don't
have to use them to be called scheme.

Kristof
 
M

M. Edward (Ed) Borasky

Thanks!! In February of 1993, I was just starting on the project that
has consumed most of my "paid programming" time since then. It started
out as Korn shell augmented with "gawk" for the more complicated pieces,
then got migrated to Perl 4 as soon as I discovered Perl 4. It picked up
the R component about 2000, but it's still mostly Perl 4. The Java 1.1
program was done in 1997.

So, going back to another thread, it looks like the "core language" of
Ruby is the object model and the Perl features. Is there by any chance a
place where I could get the Ruby 1.0 source? That might be *very*
interesting.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,734
Latest member
manin

Latest Threads

Top