Dear Meikel and Michal,

Thanks for your replies.

Meikel is right in observing that my question makes very little sense out of
context.

The reason I'm asking which Java classes can hold Clojure expressions is
that Clojuratica includes a Clojure s-expression reader, and I'm trying to
refine it. The reader allows the user to express Mathematica expressions in
Clojure syntax; for instance, the user can write the Mathematica expression
Apply[Plus, {1, 2}] as (Apply Plus [1 2]), and Clojuratica will evaluate
that expression in Mathematica even though the rest of the program is
written in Clojure. My question arises because I allow the user to unquote
*Clojure* data structures within the Clojure-syntax Mathematica expressions.
For instance, if x is the Clojure vector [1 2], I allow the user to write
(Apply Plus ~x), which evaluates to the same thing as the expression above.
But now suppose x is not a vector but a list (1 2). When the user writes
(Apply Plus ~x), I have to decide whether the list should be treated as an
expression (function 1, argument 2) or a data structure. I want the user to
be able to achieve either goal: unquote the expression (1 2) (like a macro),
or unquote the data (1 2). Hence I was trying to use the underlying Java
type to differentiate between x's that are expressions and x's that are
data: perhaps data if it's a lazy-seq, and expression if it's a cons or a
list.

However, your replies have made me realize that this approach is a mistake.
Instead, I need to decide whether x is an expression or data on the basis of
its context within the larger expression, not on the basis of its type.
That's the way Clojure does it: the seq (1 2) is always an expression,
regardless of its concrete type, unless it's quoted. So, I need to be more
precise about quoting and unquoting in Clojuratica. What I think I've
decided on is something like the following:

(def x '(1 2))

;in Clojuratica:
(Apply Plus ~x)   ; unquotes x as an expression: 1 is a function, 2 is the
argument

(Apply Plus ~~x)   ; unquotes x as data: treats x as the list (1 2)

or something along those lines. I have to try to make it congruent with
Clojure's quoting and unquoting conventions.

Thanks for your input. Your criticism of my premises made me rethink my
approach in a very constructive way.

Garth



On Mon, Feb 15, 2010 at 3:40 PM, Meikel Brandmeyer <m...@kotka.de> wrote:

> Hi,
>
> On Sun, Feb 14, 2010 at 08:58:56PM -0500, Garth Sheldon-Coulson wrote:
>
> > (Revised version: What characterizes an expression? Is it correct to say
> > that an expression is always something for which seq? returns true and
> never
> > something for which seq? returns false?)
>
> I don't think so. {:a :b} is just an expression (which evaluates to a
> map) as is 5 (evaluating to 5) as is x (evaluating to whatever x is
> bound to) as is (inc 1) (evaluating to 2).
>
> > And please consider the other questions revised as appropriate. In
> > particular, please restrict my question about quote and syntax-quote to
> > situations where they quote a form demarcated by parens. I would still
> like
> > to know whether there is anything certain about the types returned by
> quote
> > and syntax-quote when they are called on a paren-demacated form.
>
> As Clojure is based on abstractions everything relying on specific types
> should be questioned. Especially since in the future reify may kill that
> idea completely.
>
> My (certainly limited) experience with this kind of questions is: Why do
> you need to know? There may be perfectly valid reasons. Then I would go
> with seq?.
>
> Sincerely
> Meikel
>
> --
> 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<clojure%2bunsubscr...@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 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

Reply via email to