Re: Java interop with dynamic proxies

2013-03-12 Thread Brian Goslinga
Do you want to know how to define Fred, or how to translate the above code snippet? -- -- 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 - ple

Re: features expression

2013-03-06 Thread Brian Goslinga
Do we really need new syntax for feature expressions? Although it would be more ugly than CL's feature expressions, we could use a reader literal. For example #feature [ ]. Using a reader literal is simple, compatible with EDN, and allows for the feature expressions to be backported to an older

Re: What is the design guideline for =?

2012-10-20 Thread Brian Goslinga
When records were first introduced there was a little debate over what the behavior of first case should be. If = is defined solely in terms of .equals then two different records with the same key/value mappings must [1] be = to each other to obey the contract of the Map interface even though t

Re: ClojureScript Debug

2012-04-04 Thread Brian Goslinga
On Monday, April 2, 2012 8:54:07 AM UTC-5, Moritz Ulrich wrote: > > See [1]: "Agents are currently not implemented" > > They wouldn't be very useful, as javascript is single threaded in most > implementations. > > [1]: > https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure > Even

Re: clojure.io

2012-03-10 Thread Brian Goslinga
On Saturday, March 10, 2012 7:57:59 AM UTC-6, lpetit wrote: > > > > 2012/3/10 Brian Goslinga > >> On Mar 8, 3:12 pm, cej38 wrote: >> > This is a NOOB question. >> > >> > Would it be possible to write a library that could do IO without &g

Re: clojure.io

2012-03-09 Thread Brian Goslinga
On Mar 8, 3:12 pm, cej38 wrote: > This is a NOOB question. > > Would it be possible to write a library that could do IO without > resorting to the underlying VM? I would be suspicious of a cross-implementation wrapper. You'll probably end up with something as awful as the Common Lisp path API. Wor

Re: Help coding Eller's maze algorithm.

2012-01-26 Thread Brian Goslinga
On Jan 24, 4:57 pm, Gabriele Carrettoni wrote: > Hi, I'm trying to code the algorithm described > here > with > no luck. > I'm struggling to find the best data structure to hold each cell, how to > random join cells and ho

Re: multiple return values

2011-12-22 Thread Brian Goslinga
On Dec 22, 8:52 am, Razvan Rotaru wrote: > What do you mean by site? > For example, how is it when I'm creating my proxy inside a macro? (and > assuming this macro is called many times) > > (defmacro [a-class] >     (proxy (a-class) )) > > Razvan Once all code is macroexpanded, every use of pr

Re: Bug with 1.3 primitive function return value hinting.

2011-12-16 Thread Brian Goslinga
On Dec 16, 3:51 am, Meikel Brandmeyer wrote: > Hi, > > Am 16.12.2011 um 01:58 schrieb Cedric Greevey: > > > I know that every fn is a class; I am questioning the very need for > > "prim interfaces". > > If you don't have an interface, you can't redef the function at runtime. > Since the class of

Re: want to make a 'debug' function, how to get current source and line number?

2011-12-16 Thread Brian Goslinga
I believe the line number can be found in the metadata on lists that are read in by the reader. -- 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 moderate

Re: Bug with 1.3 primitive function return value hinting.

2011-12-15 Thread Brian Goslinga
On Dec 15, 10:03 pm, Cedric Greevey wrote: > So, I can wait until either larger numbers of primitive arguments are > supported, or primitive vectors are supported. We already have persistent vectors that store their contents as primitives with gvec. If you take a look at IFn.java, you'll see that

Re: on lisp and scheme macros

2011-12-06 Thread Brian Goslinga
> Does that mean that Clojure's defmacro is aware of the lexical scope as > well and is therefore equally powerful as Scheme's syntax-case? > > Bye, > Tassilo In my implementation of syntax-rules/syntax-case, I did essentially the same thing as syntax-quote (had to reimplement it as there is no pro

Re: on lisp and scheme macros

2011-12-04 Thread Brian Goslinga
You might be interested in the paper 'Fortifying Macros': http://www.ccs.neu.edu/scheme/pubs/icfp10-cf.pdf syntax-parse is very cool and can give good error messages if the user makes a mistake when using the macro. About a year ago I tried making an implementation of a system like syntax-parse f

Re: delayed recursive macro expansion?

2011-12-03 Thread Brian Goslinga
1) Write itry-fn which takes a function and the source of the function. Example usage: (itry-fn (fn [] (/ 5 0)) '(/ 5 0)) 2) Next write your itry macro to use the function: (defmacro itry [expr] `(itry-fn (fn [] ~expr) '~expr)) A general rule of thumb for macros is that they should provide sug

Re: How to deal with parameters unused by intermediate functions?

2011-12-03 Thread Brian Goslinga
In rare cases using vars + binding may be a good solution, although your functions become impure and there can be interesting interactions with laziness. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@goog

Re: scheme to clojure translation

2011-11-11 Thread Brian Goslinga
On Nov 8, 10:08 pm, Aquahappy wrote: > Hi Jim, > > Thanks so much! Using 'def' instead of 'defn' when defining a function > composed of functions was what I was missing. > > I can't believe I spent an hour trying to figure this out -- it seems > very obvious now. Doh! > > :) Notice that the Scheme

Re: clojure.core/max and NaN

2011-10-30 Thread Brian Goslinga
On Oct 30, 4:02 am, bOR_ wrote: > Hi all, > > Ran into something unexpected with "max". > > user> (sd-age-female 13)                                                   > > [10 NaN 0.746555245613119]                                                 > > user> (apply max (sd-age-female 13))            

Re: "Can't take value of a macro" aka "macro noob needs help"

2011-10-30 Thread Brian Goslinga
On Oct 30, 9:22 am, Dennis Haupt wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > i played around a bit > > (defmacro times [times & exprs] >   '(let [countdown# ~times] >      (loop [remaining# countdown#] >        (when (< 0 remaining#) >          ~@exprs >          (recur (dec remai

Re: defrecord == premature optimization?

2011-09-07 Thread Brian Goslinga
On Sep 7, 9:07 am, Stefan Kamphausen wrote: > Hi, > > yeah, maybe I should have chosen my words more wisely.  I think it comes > from my CL background where you can > > (declare (optimize (speed 3) (safety 0)) > > to achieve this behavior. Not to be nitpicking here. An Exception is > obviously 'sa

Re: On Lisp with Clojure

2011-09-06 Thread Brian Goslinga
On Sep 6, 11:20 am, Michael Jaaka wrote: > Btw. it looks like Clojure is missing an ability to program reader. > > It would allow to program a syntax. This is by design as there is no good way to namespace syntax. > The tail recursion and continuations also would be awesome. Those aren't provided

Re: defrecord == premature optimization?

2011-09-05 Thread Brian Goslinga
On Sep 5, 8:46 am, Terje Dahl wrote: > Ref:  Stuart Halloway's talk: "Simplicity": > > http://blip.tv/clojure/stuart-halloway-simplicity-ain-t-easy-4842694 > > Found via reading list:http://clojure.com/reading.html) > > At one point in his talk he states that defrecord is in fact basically > "docu

Re: An open call to the community: Let's prepare for 1.3

2011-09-03 Thread Brian Goslinga
On Sep 3, 3:13 pm, Alan Malloy wrote: > I prefer to use ^{:dynamic true} instead of ^:dynamic, unless you're > recommending intentionally breaking compatibility with 1.2 so as to > encourage people to move to 1.3. Presumably you would be doing this on a 1.3 branch of your code. -- You received t

Re: Eval in future ... Bug or feature?

2011-09-02 Thread Brian Goslinga
The future is probably executing in a different thread, so the dynamic binding of *ns* probably isn't the user namespace. -- 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 fro

Re: mutability in the let-form!?

2011-08-27 Thread Brian Goslinga
On Aug 27, 4:37 am, Terje Dahl wrote: > I was surprised to discover that the following was possible: > > (let [ >        x 1 >        y 2 >        x (+ x y) ] >      x ) > > This runs and returns 3! > > This feels an awful lot like variables and procedural programming. > It is left up to the devel

Re: New to Clojure -- Errors Are Frustrating

2011-08-03 Thread Brian Goslinga
On Aug 2, 8:39 am, Ken Wesson wrote: > It is true that the messages commonly encountered could stand to be > better documented on a Clojure site. I'm wondering if we could go > further, though, and make REPL exception printing more informative. > The Java exception gets stored in *e, so someone ca

Re: a lazy version of shuffle.

2011-07-12 Thread Brian Goslinga
On Jul 11, 5:44 am, Sunil S Nandihalli wrote: > Hello everybody, >  I think a lazy version of shuffle would be a good addtion to the core. I > tried googling for one and > foundhttp://ytakenaka.blogspot.com/2011/05/lazy-shuffle-clojure.htmlwhich was > infact slower than original shuffle and was u

Re: better error messages > smaller stack traces

2011-02-08 Thread Brian Goslinga
I have been working on a fork of Clojure to explore what can be done w.r.t. error messages: https://github.com/qbg/clojure Currently it fixes a misleading error message generated by (int [5]), it aligns the IndexOutOfBoundsExceptions with those thrown by the collections classes, and it explores the

Re: overriding seq in defrecord

2011-02-05 Thread Brian Goslinga
On Feb 5, 5:51 pm, Kees-Jochem Wehrmeijer wrote: > Well, my idea was for the type to hold a datastore query (Google App > Engine). At the moment I'm using a map for this. To get the results > from the query I have a function run-query that takes the map and > returns a seq based on an Iterable. I

Re: overriding seq in defrecord

2011-02-05 Thread Brian Goslinga
Why do you want to override seq? The only reason that I can think of is that you are implementing some sort of custom data type. If that is the case, you should be using deftype instead; defrecord is a protocol- aware drop in replacement for normal maps. On Feb 5, 2:58 pm, Kees-Jochem Wehrmeijer

Re: Enhanced Primitive Support Syntax

2011-01-17 Thread Brian Goslinga
I'll also add that type inference wouldn't solve the problem, it would just move the pain the the design of the type system and details relating to it. The type system would probably be at least as complex as Java generics to be something worthwhile if you do the type inferencing for perf primarily

Re: Enhanced Primitive Support Syntax

2011-01-17 Thread Brian Goslinga
On Jan 17, 3:17 pm, Jason Wolfe wrote: > I think you can.  Let me elaborate on my simplistic example.  Compile > the code for a function twice -- once where everything works within > primitives, and once where everything works with Objects -- and > concatenate the bytecode together.  Start by runn

Re: REPL+Laziness: the worst combination ever!

2011-01-08 Thread Brian Goslinga
On Jan 7, 7:03 pm, Nicolas Buduroi wrote: > I've been doing a lot of Clojure lately and, of all thing, > collection's laziness coupled with a REPL is what makes me loose the > most time. I really love having laziness built-in by default and I'm a > REPL-driven development addict, but sometimes I j

Re: ANN: syntax-rules

2011-01-03 Thread Brian Goslinga
On Jan 3, 7:44 am, Mark wrote: > One of the stmbling blocks I find as a Clojure newbie are syntax > errors working with core library macros.  The error messaeges aren't > always descriptive.  What are the chances that core macros could be > rewriiten using a future version on defsyntax to help wit

ANN: syntax-rules

2011-01-02 Thread Brian Goslinga
I have released version 1.0.0-alpha1 of my syntax-rules library: http://clojars.org/org.clojars.qbg/syntax-rules. This library is also on Github: https://github.com/qbg/syntax-rules This library seeks to address two sources of incidental complexity when writing macros in Clojure using defmacro: pa

Re: can I force the JIT to be called immediately for certain pieces of code after it starts executing with out waiting for the JVM realize it is necessary....

2011-01-01 Thread Brian Goslinga
On Jan 1, 8:29 pm, Sunil S Nandihalli wrote: > Hello Everybody, >  can I force the JIT to be called immediately for certain pieces of code > after it starts executing with out waiting for the JVM realize it is > necessary? I would not mind jitting the whole code .. Actually I don't > mind wait

Re: Clojure 1.3 Alpha 4

2010-12-14 Thread Brian Goslinga
On Dec 14, 9:24 pm, Ken Wesson wrote: > Breaking source compatibility with just about every single preexisting > line of Clojure code out there is supposed to make our lives *easier*? Actually, it appears that the majority of the lines of code out there use integers that fit inside a long, so the

Re: Clojure 1.3 Alpha 4

2010-12-14 Thread Brian Goslinga
On Dec 14, 8:04 pm, Ken Wesson wrote: > On Tue, Dec 14, 2010 at 8:23 PM, Benny Tsai wrote: > > As Brian said, primitive math is now the default in 1.3.  If auto- > > promotion on overflow is desired, you can use the +', -', *', inc', > > dec' functions (note the single quote suffix). > > Why was

Re: Clojure 1.3 Alpha 4

2010-12-14 Thread Brian Goslinga
On Dec 14, 6:30 pm, Miki wrote: > (defn fact [n] (reduce * (range 1 (inc n > (fact 100) > > This produces the right result on 1.2 but "ArithmeticException integer > overflow" on 1.3-alpha4. > Is this intentional? Primitive math is the default in 1.3 -- You received this message because you a

Re: Incorrect behaviour for large s-expressions :(

2010-11-15 Thread Brian Goslinga
On Nov 13, 11:48 pm, Robert McIntyre wrote: > So my friend and I were screwing around, battling versions of LISP as > nerds are wont to do, when I came across this: > > (eval `(clojure.core/+ ~@(take 1e4 (iterate inc 1 > Invalid method Code length 89884 in class file user$eval13607 > > This is

Re: cool compiler-project?

2010-08-24 Thread Brian Goslinga
On Aug 18, 7:35 am, Sreeraj a wrote: > Hi, > I am a post-grad student looking for a cool compiler - project to do. > I am getting comfortable with clojure and would really like to help > > Ideas anyone? > or, Is there a to-do list where can i start? > > Cheers > Sreeraj An idea: Use knowledge of

Re: let binding ~'=

2010-08-21 Thread Brian Goslinga
On Aug 21, 9:58 am, limux wrote: > Is where a canonical doc about ~' or I have to read the core.clj? ~' is not an actual thing. Note that `~expr is the same as expr, so `~'foo is the same as 'foo is the same as (quote foo), which when evaluated yields the symbol foo. -- You received this messag

Re: What is the reason Lisp code is not written with closing parenthesis on new lines?

2010-08-19 Thread Brian Goslinga
On Aug 19, 1:55 am, michele wrote: > Thanks everyone for the your answers (and the internal debates). I > will not put closing parenthesis on new lines. Even though the editor > helps me with the parenthesis, there have been situations - while > editing inside functions - that I had to count them.

Re: What is the reason Lisp code is not written with closing parenthesis on new lines?

2010-08-18 Thread Brian Goslinga
Putting them on separate lines put the focus on the wrong element of the code. You do not want to be focusing on the parentheses, you want to be focusing on the structure of the code. The idiomatic lisp formatting style uses indentation to reveal the large scale structure of the code, and so the

Re: Nil Coalesce

2010-08-17 Thread Brian Goslinga
If solving a more general problem first counts as elegant, then here is a solution: (defn map-replace "Return coll but replace every element for which pred returns true with (f element replacement-element) as long as there are replacement elements in replacements" [pred f coll replacements]

Re: Counterclockwise version 0.0.59.RC2

2010-07-06 Thread Brian Goslinga
Indentation in default structural mode would be nice. The behavior for ), ], and } from strict structural mode should be moved into default mode; without it, I have to do a lot of deleting extra characters or manually move the cursor around, which makes default mode almost unusable. -- You recei

Re: Clojure's n00b attraction problem

2010-06-30 Thread Brian Goslinga
On Jun 30, 12:50 pm, David Nolen wrote: > On Wed, Jun 30, 2010 at 1:42 PM, cageface wrote: > > I don't know what the implementation plans are exactly for clojure-in- > > clojure but abandoning the JVM would be extremely unwise. > > Clojure-in-Clojure isn't about abandoning the JVM. It's about imp

Re: Enhanced Primitive Support

2010-06-19 Thread Brian Goslinga
On Jun 19, 2:24 pm, Mark Engelberg wrote: > On Sat, Jun 19, 2010 at 12:20 PM, Nicolas Oury wrote: > > Not "ordinary" code. 10^19 is big. > > Nicolas, I think you misunderstand my point.  I'm talking about > loop/recur behavior.  If you initialize a loop with the literal 1, and > then recur with a

Re: Funding Clojure 2010

2010-01-14 Thread Brian Goslinga
I think it would be useful if there was some way to (mostly) automatically donate $10/month. -- 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: Swing unit testing

2010-01-12 Thread Brian Goslinga
On Jan 12, 8:39 am, Eric Thorsen wrote: > Anyone have any recommendation/experience for a unit testing library > for testing swing components? > > Thanks! > Eric We've used FEST [1] in school. It worked, but testing GUI code is horrible. [1] http://fest.easytesting.org/wiki/pmwiki.php -- You re

Re: gui repl

2010-01-04 Thread Brian Goslinga
Nice. This reminds me of some of the things you can do in CLIM. -- 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

Re: eval performance

2009-12-23 Thread Brian Goslinga
If you are doing GP, another approach to avoid using eval would be using a tree of closures. http://xach.livejournal.com/131456.html is an example of the technique used in Common Lisp (should be similar enough). -- You received this message because you are subscribed to the Google Groups "Clojur