2009/12/15 ajay gopalakrishnan <ajgop...@gmail.com>

> Oh ... I know all that. What I wanted to know is that is there any way to
> FORCE compile time checking by providing some flag or the other to Clojure
> compiler. If not, I guess a good set of test cases is the only way to fix
> it. (Good test cases are always recommended, it's just that in this case it
> becomes unavoidable)
>

Not yet, and - just guessing - neither in a short nor middle term.

But I remember Rich mentioning being interested in type systems "a la" Qi
language ( http://en.wikipedia.org/wiki/Qi_(programming_language) ). This
allows to enable/disable type checking, but maybe what seemed more
interesting was the way to define the type via sequent calculus (
http://en.wikipedia.org/wiki/Qi_(programming_language)#Type_Checking ).

HTH,

-- 
Laurent


>
> Ajay
>
>
> On Tue, Dec 15, 2009 at 7:23 AM, Baishampayan Ghose 
> <b.gh...@ocricket.com>wrote:
>
>> Ajay,
>>
>> > It tried the following in REPL and got no error. Personally, I feel that
>> > I should get an error because calling square on strings is wrong in both
>> > cases.
>> >
>> > Is there a way out of this in Clojure?
>> >
>> > |(defn square[n]  (*  n n))
>> >
>> > (if  (=  0  0)  (println"hello")  (map square["a"  "b"]))
>> >
>>
>> What did you expect from Clojure? In the above form the `map` is a part
>> of the else form and that's why it's not executed.
>>
>> If you don't know already, the syntax for `if` in Clojure is like this -
>>
>> (if expression
>>   (then form)
>>   (else form))
>>
>> If you have multiple then or else forms, you can wrap them inside a `do`
>> form like this -
>>
>> (if expression
>>   (do
>>     (then form)
>>     (more then form))
>>   (else form))
>>
>> > The following gives error (because it gets evaluated):
>> >
>> > |(defn square[n]  (*  n n))
>> >
>> > (if  (=  0  1)  (println"hello")  (map square["a"  "b"]))
>>
>> In the above form, the map is a part of the else form and since 1 is not
>> equal to 0, the `map` is executed.
>>
>> I hope your confusion is cleared.
>>
>> PS - If you are worried about "compile time type checking", I think it's
>> prudent to mention now that Clojure is a dynamically typed programming
>> language where types are checked at run-time and not compile time.
>>
>> Regards,
>> BG
>>
>> --
>> Baishampayan Ghose <b.gh...@ocricket.com>
>> oCricket.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<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<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