Is this a good idea? (merging let, cond and ->)

2011-04-14 Thread icemaze
I was developing this project of mine, which has an intricate business logic, and I wrote a macro that makes programming this kind of stuff more comfortable. It's called "ilet", which stands for "implicit let". The name is probably no longer appropriate, since I added more features to it, but I can

Re: Is there a way to make a symbol throw an exception, when it's referenced?

2011-04-02 Thread icemaze
Thank you for your insights. You guys seem to think I'm doing something wrong, and you may be right. I'll see if I can come up with an alternative solution. Damn bone-head of mine. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group

Is there a way to make a symbol throw an exception, when it's referenced?

2011-04-02 Thread icemaze
I'm writing a macro that defines a symbol through let, but I also needs to unbind (unlet?) it, so that further uses of that symbol throw an exception. I hoped I could use symbol-macrolet, but local symbols are protected from expansion Thanks! -- You received this message because you are subscri

Re: A multiple-inheritance prototype system

2011-03-07 Thread icemaze
> It looks like you're trying to group together different functionality > in one place. Idiomatic Clojure tends to encourage separating > functionality out into independent components. Thanks for the tip. My system doesn't provide validation, it just differentiates between "nil" and "undefined but

A multiple-inheritance prototype system

2011-03-07 Thread icemaze
Hi clojure developers! I recently wrote an alternative datatype system for a project of mine, because requirements were a little odd and I couldn't find anything appropriate. My questions are: 1) Was this necessary at all? Can my requirements be fulfilled with off-the-shelf clojure libraries or c

Re: Possible bug in with-symbol-macros, interacts badly with case

2010-09-13 Thread icemaze
I digged a little and I have a patch. I modified the case* parser in Compiler.java, so the patch shouldn't affect anything else: I prefer keeping safe since my knowledge of Clojure internals is limited, but a more radical solution might be desirable. The problem seems caused by the way case* gets

Re: Possible bug in with-symbol-macros, interacts badly with case

2010-09-12 Thread icemaze
I found a workaround: (use 'clojure.contrib.macro-utils) (defsymbolmacro one 1) (defn bug1 []   (with-symbol-macros (bug2))) (defn bug2   (case 0     0 one))) The "one" symbol macro is there just to show that everything works as expected. -- You received this message because you are sub

Possible bug in with-symbol-macros, interacts badly with case

2010-09-12 Thread icemaze
I wrote a test case: (use 'clojure.contrib.macro-utils) (defn bug? [] (with-symbol-macros (case 0 0 1))) The REPL prints: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.MapEntry (NO_SOURCE_FILE:4) Can anyone confirm this, please? -- You

Re: Generating functions programmatically

2010-09-11 Thread icemaze
Yes, Kent's solution is spot on! Thank you all for your insights, I believe we have a winner. -- 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

Re: Generating functions programmatically

2010-09-11 Thread icemaze
Hi Btsai, thank you for your offer for help. As I said before I *could* use literals but it wouldn't be convenient. I have a big structure which contains information about "types" (they are types of domain-specific objects). I would like to extract the "methods" I need from this structure and defi

Re: Generating functions programmatically

2010-09-10 Thread icemaze
You are mostly right in your assumptions: I could dump the keywords in the clj as literals but it would be tedious and not elegant at all. Eval's not pretty but it works; plus it's there for a reason, like working around the shortcomings of the language (and of my brain). I was about to post my so

Re: Generating functions programmatically

2010-09-10 Thread icemaze
Yes, I think I'll have to pass the keywords as literals. I don't think there's a way around that (other than using eval, as per Alan's solution). I was too excited about Hubert's hint and I found myself in the exact same problem with the second macro. -- You received this message because you are

Re: Generating functions programmatically

2010-09-10 Thread icemaze
I agree: eval never looks pretty. -- 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 fr

Re: Generating functions programmatically

2010-09-10 Thread icemaze
Yeah, I guess I could use a macro to generate the "call" to the other macro in a way similar to how you used it. Thank you, that should definitely work. I'll try it right now. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send

Re: Generating functions programmatically

2010-09-10 Thread icemaze
Alan, thank you for your reply. Unfortunately your solution is very similar to mine and it suffers from the same problem (maybe I'm using it incorrectly, I don't know). If I write: (doseq [x '(:a :b)] (make-fn x)) it defines a single function "synthetic-x". Is there a way to make this work?

Generating functions programmatically

2010-09-10 Thread icemaze
Hi, I'm developing a small DSL with Clojure and I need to define many similar functions. I'd like to do that programmatically, of course. My solution (involving a simple macro) doesn't work, so I won't bother you with it. I'll post it if anyone asks. Basically what I need is: given a list of keyw

Lisp indenter for Kate

2009-09-10 Thread icemaze
I wrote a Kate script to make lisp development on Kate a little more pleasant. It was written primarily with Clojure in mind, so it should work best with this language, but it's pretty generic. If you use Kate, please try it and feel free to add a comment to the kde bug report (see below). You c

Re: Tight loop performance

2009-09-07 Thread icemaze
@Christophe: thanks, your hint helped. @B Smith-Mannschott: > Questions about how best to optimize clojure code to approach java > performance have come up with fair regularity in the past. You might > find some good ideas if you search through the archives a bit. I see. As I said before (OP),

Re: Tight loop performance

2009-09-06 Thread icemaze
Nicholas, thank you for your reply. I applied the change you suggested. Unfortunately it skimmed only about 50ms from each exectuion. Even though I'm using aset, java.lang.reflect.Array.setByte *still* uses ~25% of execution time. This means two things: A) Reflection is still used for this code.

Tight loop performance

2009-09-06 Thread icemaze
Hello! First of all, let me congratulate with the devs for their great work: I've been using Clojure for just a couple of weeks and I had a lot of fun learning it and experimenting with it. I'm starting a concurrency-heavy project and I feel Clojure is gonna be a great choice! I'm thinking about

Re: Newbie - the method I cannot call

2009-08-25 Thread icemaze
On Aug 25, 5:51 pm, tmountain wrote: > Clojure 1.1.0-alpha-SNAPSHOT Maybe it was a bug and they fixed it. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@

Re: Newbie - the method I cannot call

2009-08-25 Thread icemaze
Hey, this works! Thanks!! I was wondering... why doesn't casting work? i.e. (.open (cast SourceDataLine sdl) fmt (* 48000 2 2)) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, s

Re: Newbie - the method I cannot call

2009-08-25 Thread icemaze
On Aug 25, 4:50 pm, tmountain wrote: > I'm pretty sure your issue is that format is a function inside > clojure.core, so it's causing a conflict. I renamed it, and the code > seems to work on my machine. Using another name, unfortunately, doesn't fix the problem here. But the fact the my program

Newbie - the method I cannot call

2009-08-25 Thread icemaze
Hi, I've been struggling with this problem for some time and I don't understand why this doesn't work. I'm trying to call the "open" method of a javax.sound.sampled class but it throws the following exception: No matching method found: open for class com.sun.media.sound.DirectAudioDevice$Direc