Re: Homoiconicity in clojure (macro power)

2011-11-03 Thread Craig Brozefsky
Alex Baranosky alexander.barano...@gmail.com writes:

 Julian,

 I saw no flames fired from Craig - and I am particularly intrigued by non-Lisp
 languages such as Ioke that are homoiconic and have macros.

I meant my comment as a pre-emptive joke to derail a replaying of the
old tale of Dylan, the lisp with infix syntax.  c.l.l archives are
available if people want to see very long discussions of it.  I actually
sense that the clojure community is over that kind of inferiority
complex about syntax and parens.

Formal homoiconicity is not sufficient IMO, when the goal is the ability
to construct new code easily.  In short, I think it's code as data, and
that data being easily composed and transformed.  That ease with lisps,
IMO, comes from the nature of lists of atoms, and the support for
controlling the time of evaluation for subelements -- meaning the ` and
, and @ operators.  It's useful in alot more places than just macros
too.

I do alot of Ruby, and use class|instance_eval %{ ... } quite a bit for
metaprogramming.  Ruby is not homoiconic, but I find the %{ ... } syntax
sufficient for most of my needs, but quite brittle and subject to alot
of trial and error to figure out just how it's going to interpret a
generated token.  And of course, string/token interpolation is nowhere
near as powerful as programmatically generating lists -- even if many
macros examples are just interpolating atoms into quoted lists).  

Hmm, perhaps this tells you just how unsophisticated my Ruby
metaprogramming is, heh.

I've yet to fully grok Clojure namespaces, and its reader's design
decisions, so I can't comment on reader macros other than I initially
missed them.  I grew fond of them after using some in UncommonSQL for
the embedded SQL syntax.  However, managing the reader-table, and which
reader macros where active or needed at a given time, was rather
informal and prone to confusion.  The win of some syntactic brevity is
not that big a deal.

-- 
Craig Brozefsky cr...@red-bean.com
Premature reification is the root of all evil

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Homoiconicity in clojure (macro power)

2011-11-02 Thread Jeff Heon
This is the explanation that really made it click for me:

The nature of Lisp
http://www.defmacro.org/ramblings/lisp.html

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Homoiconicity in clojure (macro power)

2011-11-02 Thread Lee Spector

On Oct 31, 2011, at 5:40 AM, vikbehal wrote:

 I am from java Background. We say Homoiconicity in Clojure (Lisp).
 Code is data and data is code. I read various blogs on it, still not
 clear, Can you give me some example?

FWIW I think that homoiconicity can be useful in a variety of circumstances 
even when macros aren't involved.

I work with genetic programming, in which code is generated randomly, tested, 
mutated, recombined, etc. Doing this in a homoiconic language is particularly 
elegant. A very simple example that I wrote in Clojure for a class that I'm 
teaching is at: https://gist.github.com/1297325 (Many of you will notice that I 
could have written inject and extract more simply with zippers or 
clojure.walk; I avoided them here, and did some other things in the way that I 
did, for pedagogical reasons.)

 -Lee

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Homoiconicity in clojure (macro power)

2011-11-01 Thread Julian
There are some examples of homoiconicity in other languages here:
http://c2.com/cgi/wiki?HomoiconicExampleInManyProgrammingLanguages
(being TCL, Joy and Io)
 
Also worth noting is the recent work by Ola Bini on Ioke. 

Another interesting homoiconic language was Apple's Dylan language - which 
transitioned from leading parentheses and prefix expressions (both 
S-Expressions) to  infix expressions and a more C-like syntax:
http://en.wikipedia.org/wiki/History_of_the_Dylan_programming_language#The_roots_of_changing_the_syntax_from_lisp_way_to_an_infix_one
 
I wonder what would be required for a modification to the clojure reader in 
order to do this...

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Homoiconicity in clojure (macro power)

2011-11-01 Thread Craig Brozefsky
Julian juliangam...@gmail.com writes:

 I wonder what would be required for a modification to the clojure reader in
 order to do this...

No intention of picking on Julian, but do we really have to re-live all
of the flamewars and jawflapping of comp.lang.lisp on the clojure group
again?  You're giving me flashbacks 8^)



-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Homoiconicity in clojure (macro power)

2011-11-01 Thread Julian
Julian julian...@gmail.com writes: 

 I wonder what would be required for a modification to the clojure reader 
in
 order to do this... 

No intention of picking on Julian, but do we really have to re-live all
of the flamewars and jawflapping of comp.lang.lisp on the clojure group
again?  You're giving me flashbacks 8^) 

My apologies, my intention was to provide a thinking scenario, rather than 
troll for a flamewar. If that's the probable outcome then let's drop it, 
and make a mature decision to focus on something else. 

Cheers to the Clojure community. 

JG 

 

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Homoiconicity in clojure (macro power)

2011-11-01 Thread Alex Baranosky
Julian,

I saw no flames fired from Craig - and I am particularly intrigued by
non-Lisp languages such as Ioke that are homoiconic and have macros.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Homoiconicity in clojure (macro power)

2011-10-31 Thread daly
While Peter Norvig was discussing Python with John McCarthy
(inventor of lisp) in the audience:

John simply asked if Python could gracefully manipulate
Python code as data.

No, John, it can't was Peter's reply.

Create a list and call read on it.
Create a function, manipulate it as a list to modify it,
walk it, print it, and treat it as a list in general.

In particular, a macro is a list that operates on a
list to produce a list that gets used as a list, possibly
to define a data structure, or a function, or another
macro or whatever else you might want.

Lisp code is data. Lisp data is code.
This is not true in most other languages.

Tim Daly

On Mon, 2011-10-31 at 02:40 -0700, vikbehal wrote:
 I am from java Background. We say Homoiconicity in Clojure (Lisp).
 Code is data and data is code. I read various blogs on it, still not
 clear, Can you give me some example?
 


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Homoiconicity in clojure (macro power)

2011-10-31 Thread Baishampayan Ghose
 I am from java Background. We say Homoiconicity in Clojure (Lisp).
 Code is data and data is code. I read various blogs on it, still not
 clear, Can you give me some example?

Using macros it's possible to add new syntax to the language which
is extremely hard (if possible at all) to achieve in non-homoiconic
languages.

As an exercise, try writing the `or' function in Java and then take a
look at the Clojure implementation -
https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L789

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.com

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en