On Sun, Nov 30, 2008 at 3:54 PM, André Thieme
<[EMAIL PROTECTED]> wrote:
>
> On 30 Nov., 19:15, "Mark Volkmann" <[EMAIL PROTECTED]> wrote:
>
>> Related to this is the idea that maybe the REPL should automatically
>> wrap a line without parens with them. That way you could just enter
>> "quit" instead of "(quit)". That seems handy for many things. For
>> example, why not enter
>>
>> println "my-var is" my-var
>>
>> instead of
>>
>> (println "my-var is" my-var)
>>
>> It's entirely possibly I'm overlooking some reason why this is a bad idea.
>
> There are two reasons why the parens exist in Lisp.
> The main reason is: functions taking any number of arguments.
> If you have functions like that you will need two delimiters,
> to mark the begin of a function call and the end.
>
> (+ 1 2 (* 3 4)) is clear.
> (+ 1 2 * 3 4) is not.
> Does it mean (+ 1 2 (*) 3 4) ==> 11   ;because (*) ==> 1
> Or is it (+ 1 2 (* 3) 4) ==> 10 ?
> Or is it (+ 1 2 (* 3 4)) ==> 15 ?
>
> The example you gave, with println is not a good one, because
> println is such a function that takes any number of args.
> What if we have (def my-var (fn [] 4))?
> Is   println "my-var =" my-var  then
> (printn "my-var =" my-var) --> prints:
> my-var = #<user$my_var__1970 [EMAIL PROTECTED]>
> or is it (println "my-var =" (my-var)) --> prints:
> my-var = 4

It's the first option.

> Only for those cases where the functions take a fixed number
> of arguments you could do that.
> (defn add [a b] (+ a b))
> (defn mul [a b] (* a b))
>
> Now   add 3 mul 5 5  is always clear, no parens needed.
> But  + 3 * 5 5  is not clear. We don't know if we want to
> put the * function into +, which would cause an error
> because + is not defined to add numbers to function
> objects, or do we want to apply * to one or both fives?

I think you misunderstood what I was suggesting. I was only referring
to expressions entered in a REPL, not expressions in a file of Clojure
code. At the REPL it would be easy to check whether the single line
entered is surrounded by parens and add them if they are missing.
However, others have raised a concern about what that would to do
simply evaluating a symbol. I wouldn't want to lose that capability
either.

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~---------~--~----~------------~-------~--~----~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to