Hi there,

Before I go on, I'll apologize as this might get long and vague in
parts.  That will just be my showing where I'm even more confused than
I generally am.  I have only recently started trying to learn Clojure
and by inference Lisp.

Last night, I watched this video - 
http://blip.tv/clojure/clojure-for-java-programmers-1-of-2-989128.
Admittedly though there were more than a few parts which flew right
over my head, I took those as a prompt for further reading.  This
morning though the question of the "IF" primitive struck me.

Basically, in this video Rich Hickey tells us that if is one of only a
few primitive statements and it can not be a function because it is
composed of two functional blocks of which only one is used at a
time.  This made sense and is reminiscent of what I've read about lisp
elsewhere.

This part doesn't make much sense but I'm including it to build the
context of the actual question when I get to that, this will I hope
make it more straight forwards.
This morning I was thinking what if all your operands and data were
predicated and the compiler were able to see some sort of
environmental variable then you could build an "IF" like function or
macro.  Armed with this different perspective I realised I'd seen it
before but also by itself it doesn't make much sense in a high level
language.

First of all, operands and data by themselves don't need to be
predicated and it would cause everyone a lot of work.  Then also the
compiler doesn't need to be aware of any special environmental
variables either for the same reason as before.

However, I think there is scope for consideration of a predicated code
block which returns a data structure or object or function or more or
less what ever would be the appropriate thing for Clojure to return.
Using this predicated code block structure "IF", "AND", "OR", "NOT",
"Select Case" would all be able to be macros constructed using this
primitive.

As I imagine it there would be two possible syntax variations that
might implement this.

The first like the "LET" would be in the form ("Logical-Predicate-
Primitive" "Test-Expression" ("Scope-A") ("Scope-B") ("Scope-C")).  In
the case of "Test-Expression" = TRUE then "Scope" is returned
otherwise NIL.  You can have as many "Scope-s" as you like.

The second is much more dramatic.  At the moment in Lisps a list of
symbols (A B C) is read in and then A is evaluated looking for a
function.  If A is not a function then (I think) an error is thrown
but either way it's not proper lisp expression by itself.  Even if at
some point previously there had been a (def A 5), the value 5 isn't a
function either so nothing good happens.
The second case would work something like this (("Test-Expression")
("Scope-A") ("Scope-B") ("Scope-C")) which as above would allow you to
have as many "Scope-s" as you like.  In this case though with the list
(A B C), A is testable as an empty symbol pointing to Nil or when (def
A 5) has occurred it would be treated as always TRUE and then B and C
are evaluated normally.

So basically what I'm proposing is a conditional code block which
would take the place of the "IF" primitive.  I have briefly searched
for examples of where this kind of thing might have been discussed
before but as "IF" is a very common operator, I didn't find anything
illuminating.

After all that my questions;

        Has this been discussed before?
                If so what were the conclusions?
                Such as the Pros and Cons of "IF" verses a predicate
code block?

        If this was an in appropriate question to address to you, do
you have any idea to whom I would be better addressing it?

        In the case that this is a new topic, what do you think?


--
Kind regards

Stephen Feyrer.

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to