Re: 4Clojure exersice question

2012-01-13 Thread Cedric Greevey
On Fri, Jan 13, 2012 at 6:47 PM, Anthony Grimes wrote: > Clojail errs on the side of safety and not on the side of "Oh, well maybe he > wasn't trying to break the sandbox. Let's allow it anyway.". Treating macros > as opaque is just another hole in what is already difficult sandboxing. > Macros ar

Re: 4Clojure exersice question

2012-01-13 Thread Cedric Greevey
On Thu, Jan 12, 2012 at 3:31 AM, markus wrote: > Computers don't accuse, they process data. And they are not (yet?) > capable of reading a user's intentions. Technically no, but it's doubtful that a user using a macro like "for" intends to "cheat", so from the *programmer's* standpoint it's not c

Re:

2012-01-11 Thread Cedric Greevey
You'll need to be a bit more specific. -- 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 unsubscri

Re: 4Clojure exersice question

2012-01-11 Thread Cedric Greevey
It seems dubious to me that it accuses users of cheating when they clearly had no intent to cheat. Is this intended behavior of 4Clojure or a bug? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroup

Re: Problem with :pre checks against nil in 1.3.0?

2012-01-09 Thread Cedric Greevey
On Mon, Jan 9, 2012 at 12:53 PM, Tom Chappell wrote: > Ok, I've got a couple thousand lines of Clojure under my belt, but > this has me stumped, unless it's a compiler etc. issue.  If I'm > missing something dumb, what is it, please? > > I have a function that is failing a not-nil precondition.  H

Re: ANN: core.unify v0.5.2

2012-01-09 Thread Cedric Greevey
On Mon, Jan 9, 2012 at 3:43 PM, Jay Fields wrote: > On Mon, Jan 9, 2012 at 3:20 PM, Cedric Greevey wrote: > >> Talk about completely missing the point. > > I had no idea what core.unify would be used for either. However, the > email included a link to the github page,

Re: ClojureScript – inter-namespace usage

2012-01-09 Thread Cedric Greevey
On Mon, Jan 9, 2012 at 2:20 PM, Shantanu Kumar wrote: >> #3 seems unlikely to be implemented. ClojureScript doesn't have Vars, and >> it doesn't have threads, so there's not much for `binding` to do. I could >> see `with-redefs` being supported, however. > > Hi Stuart, > > Thanks for the pointers.

Re: ANN: core.unify v0.5.2

2012-01-09 Thread Cedric Greevey
On Mon, Jan 9, 2012 at 2:16 PM, Michael Fogus wrote: >> Not really, not with a single fairly generic word like "unification". > > In the amount of time that you spent lecturing me on good library > release note practices you could have learned what unification was, > read the code, and decided if

Re: ANN: core.unify v0.5.2

2012-01-09 Thread Cedric Greevey
On Mon, Jan 9, 2012 at 2:08 PM, Sean Corfield wrote: > On Mon, Jan 9, 2012 at 11:00 AM, Cedric Greevey wrote: >> On Mon, Jan 9, 2012 at 1:45 PM, Michael Fogus wrote: >>> Google also helps too. :-) >> Not really, not with a single fairly generic word like "unificati

Re: ANN: core.unify v0.5.2

2012-01-09 Thread Cedric Greevey
On Mon, Jan 9, 2012 at 1:45 PM, Michael Fogus wrote: >> Yes, but what exactly are these "unification binding, subst, and >> unification functions"? > > This is information that seems a bit odd to include in a set of > release notes, but I suppose a link to where such information could be > found i

Re: ClojureScript – inter-namespace usage

2012-01-09 Thread Cedric Greevey
On Mon, Jan 9, 2012 at 1:18 PM, Stuart Sierra wrote: > #3 seems unlikely to be implemented. ClojureScript doesn't have Vars, and it > doesn't have threads, so there's not much for `binding` to do. I could see > `with-redefs` being supported, however. Actually, the lack of threads just simplifies

Re: Templating, how to?

2012-01-09 Thread Cedric Greevey
On Mon, Jan 9, 2012 at 10:36 AM, Linus Ericsson wrote: > I want to generate rules with constant and/or functions producing parts of > the rules: > > (defn rulemaker [] >    (str "SCOPE " global-constant ";" (some-global-function) ";")) > > which could be called with > > (with-super-closure model-i

Re: Help with binding

2012-01-09 Thread Cedric Greevey
On Mon, Jan 9, 2012 at 7:48 AM, Matthew Giannini wrote: > Cedric - thanks. I'm new to Clojure and after posting this realized that I > could/should use one of the do* approaches. I ended up using doseq and it > worked great. > > Thanks. You're welcome. -- You received this message because you a

Re: Difference between clojure.lang.Cons and clojure.lang.PersistenList

2012-01-09 Thread Cedric Greevey
On Sun, Jan 8, 2012 at 4:11 PM, Samuel Lê wrote: > Yes, seq? works. Thanks for the help! You're welcome. -- 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 a

Re: ANN: core.unify v0.5.2

2012-01-09 Thread Cedric Greevey
On Mon, Jan 9, 2012 at 8:00 AM, Fogus wrote: > core.unify v0.5.2 Release Notes > === > > core.unify is a Clojure contrib library providing the following > features: > > * Factory functions for constructing unification binding, subst, and > unification functions, with or

Re: Difference between clojure.lang.Cons and clojure.lang.PersistenList

2012-01-08 Thread Cedric Greevey
On Sun, Jan 8, 2012 at 10:30 AM, Samuel Lê wrote: > Hi and Happy New Year to all the Clojure mailing list, > > I am am having some trouble with the two classes Cons and PersistentList: > > user> (class (conj (map #(+ % 1)  '(1 2 3)) 4)) > clojure.lang.Cons > user> (class '(1 2 3 4)) > clojure.lang

Re: Help with binding

2012-01-08 Thread Cedric Greevey
On Fri, Jan 6, 2012 at 9:25 AM, Matthew wrote: > (defn id3-encode >  ([] (id3-encode test-out)) >  ([file] >    (with-open [out (-> (File. file) (FileOutputStream.) > (BufferedOutputStream.) (DataOutputStream.))] >      (binding [*out* out] >        (map #(write-a :byte %) [\I \D \3]) > > When

Re: Digest for clojure@googlegroups.com - 8 Messages in 6 Topics

2012-01-07 Thread Cedric Greevey
On Sat, Jan 7, 2012 at 8:01 AM, wrote: > Sent using BlackBerry® from Orange > > From: clojure@googlegroups.com > Sender: clojure@googlegroups.com > Date: Sat, 07 Jan 2012 00:21:58 + > To: Digest Recipients > ReplyTo: clojure@googlegroups.com > Subject: Digest

Re: On using atoms together with side effect functions

2012-01-06 Thread Cedric Greevey
On Fri, Jan 6, 2012 at 11:28 PM, Alan Malloy wrote: > but if you look at the post There is no call for taking a rude tone. I correctly answered the question as originally posed. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group,

Re: On using atoms together with side effect functions

2012-01-06 Thread Cedric Greevey
On Fri, Jan 6, 2012 at 10:22 PM, Alan Malloy wrote: > On Jan 6, 6:16 pm, Cedric Greevey wrote: >> On Fri, Jan 6, 2012 at 4:34 PM, Alan Malloy wrote: >> > On Jan 6, 12:56 pm, Jozef Wagner wrote: >> >> Thank you, >> >> >> But the things are more co

Re: On using atoms together with side effect functions

2012-01-06 Thread Cedric Greevey
On Fri, Jan 6, 2012 at 4:34 PM, Alan Malloy wrote: > On Jan 6, 12:56 pm, Jozef Wagner wrote: >> Thank you, >> >> But the things are more complicated. In my case, I need to update the atom >> with the result of a (native) function which unfortunately also performs >> some side effects and cannot b

Re: question from wikibooks page on macros?

2012-01-06 Thread Cedric Greevey
On Fri, Jan 6, 2012 at 11:12 AM, Andrew wrote: > http://en.wikibooks.org/wiki/Learning_Clojure/Macros > > The page says the following: > > (def pointless (fn [n] n)) > > "Whatever is passed to this macro---a list, a symbol, whatever---will be > returned unmolested and then evaluated after the call

Re: Sort a vector and keep the elements' indexes

2012-01-06 Thread Cedric Greevey
On Fri, Jan 6, 2012 at 10:29 AM, Jonathan Cardoso wrote: > Hi! I have a small stupid question and I hope you guys can help me... > > I wanted to sort a vetor, say [25 5 70] but I can't just use any sort > algorithm because later I will need to get the index of the element in the > original vector.

Re: accessing multiple return values

2012-01-03 Thread Cedric Greevey
On Tue, Jan 3, 2012 at 6:05 PM, meb wrote: > I see two fairly straightforward paths to simulating multiple returns > without breaking existing callers. Both take advantage of thread-local > state and establish one convention for the caller ... Both of them have reentrancy problems -- in the push-

Re: [ANN] swank-clojure 1.3.4 released

2012-01-03 Thread Cedric Greevey
On Tue, Jan 3, 2012 at 12:32 PM, Phil Hagelberg wrote: > Cedric Greevey writes: > >> Seriously, though. Terminals? Escape codes? Impedance mismatches >> involving term types and escape codes? What is this, the Dark Ages? >> Those kinds of problems simply should no

Re: Where is ltrim?

2012-01-03 Thread Cedric Greevey
On Tue, Jan 3, 2012 at 6:11 AM, James Reeves wrote: > On 3 January 2012 11:06, Cedric Greevey wrote: >> There's a problem, though: the str-utils2/ltrim function seems to be >> missing. This is a breaking change for some code I'm porting from 1.2 >> to

Where is ltrim?

2012-01-03 Thread Cedric Greevey
The clojure.string namespace has replaced clojure.contrib.str-utils and clojure.contrib.str-utils2. There's a problem, though: the str-utils2/ltrim function seems to be missing. This is a breaking change for some code I'm porting from 1.2 to 1.3. Where is that function now? -- You received this

Re: [ANN] swank-clojure 1.3.4 released

2012-01-02 Thread Cedric Greevey
On Tue, Jan 3, 2012 at 12:28 AM, Baishampayan Ghose wrote: >> Getting colors outside M-x clojure-jack-in requires a couple extra steps >> I forgot to document, I just added it here: >> >> https://github.com/technomancy/swank-clojure/commit/94fa71f90e52c55d74 > > Thanks, the above steps worked--alm

Re: accessing multiple return values

2012-01-02 Thread Cedric Greevey
On Mon, Jan 2, 2012 at 2:16 PM, Tassilo Horn wrote: > nchurch writes: > > Hi, > >> Someone was asking on the list here about multiple return values, >> which Clojure does not have. >> >> If the facility were ever added, perhaps multiple values could be >> accessed via namespaces.  Functions would

Re: Prefix tree creation in clojure

2012-01-02 Thread Cedric Greevey
On Mon, Jan 2, 2012 at 5:28 PM, Stephen Compall wrote: > On Sun, 2012-01-01 at 23:16 -0500, Cedric Greevey wrote: >> And that will obviously be chock-full of internals changes and >> miscellaneous tweaks and not just the user-visible feature >> changes/additions, aimed

Re: Prefix tree creation in clojure

2012-01-01 Thread Cedric Greevey
On Sun, Jan 1, 2012 at 11:09 PM, Cedric Greevey wrote: > On Sun, Jan 1, 2012 at 10:31 PM, Stephen Compall > wrote: >> On Sun, 2012-01-01 at 22:10 -0500, Cedric Greevey wrote: >>> Odd that this isn't named not-empty? with a ? character. >> >> Not at all;

Re: Prefix tree creation in clojure

2012-01-01 Thread Cedric Greevey
On Sun, Jan 1, 2012 at 10:31 PM, Stephen Compall wrote: > On Sun, 2012-01-01 at 22:10 -0500, Cedric Greevey wrote: >> Odd that this isn't named not-empty? with a ? character. > > Not at all; it's not a predicate.  See also `every?' versus `some'. It's us

Re: Prefix tree creation in clojure

2012-01-01 Thread Cedric Greevey
On Sun, Jan 1, 2012 at 5:55 PM, Stephen Compall wrote: > On Fri, 2011-12-30 at 15:21 -0800, rahulpilani wrote: >>   1: (ns prefix-tree) > > While this is just a sample, namespaces without at least one `.' are > discouraged.  I favor the Java convention (prefix with backwards > Internet domain that

Re: Clojure list syntax sugar: f(x) notation

2011-12-30 Thread Cedric Greevey
On Fri, Dec 30, 2011 at 9:19 AM, PC wrote: > There's a very nice summary of previous attempts at this on David Wheeler's > web page:  http://www.dwheeler.com/readable/index.html > I think these ideas have some merit. I would like to have the readability > and conciseness of Python with the feature

Re: Really loving Clooj but..

2011-12-29 Thread Cedric Greevey
On Thu, Dec 29, 2011 at 10:50 PM, Erlis Vidal wrote: > Cedric, you have a really good point, I just realized it after reading your > email. After sending the original email I saw what the error was, but what I > still unable to know is how could I debug from Clooj, other than using > println, any

Re: Really loving Clooj but..

2011-12-29 Thread Cedric Greevey
On Thu, Dec 29, 2011 at 6:23 PM, Mark Engelberg wrote: > I'd also like to know whether Clooj has any debug or stacktracing > capabilities.  Also, can the Clooj repl control the print level of > infinite lazy structures? (set! *print-length* 20) (set! *print-level* 20) (.printStackTrace *e) Hav

Re: extracting the execution time of a function ...

2011-12-27 Thread Cedric Greevey
On Tue, Dec 27, 2011 at 2:03 PM, endbegin wrote: > Hi, > > I am new to learning clojure, and I am hoping there is a solution to > something that is not obvious to me ... I have a function that I want > to run multiple times, measure the time it takes to execute each > function, and put those numbe

Re: Literate programming

2011-12-22 Thread Cedric Greevey
On Thu, Dec 22, 2011 at 11:59 PM, nchurch wrote: > What I really want you to notice is how we are faced with a choice: > either we improve the library code (presumably by making split > optionally return an array of separators matched by the regex for > later reassembly by join, perhaps in metadat

Re: Why are body-macros more fashionable than thunks?

2011-12-22 Thread Cedric Greevey
On Thu, Dec 22, 2011 at 4:54 PM, Peter Danenberg wrote: > Scheme, for instance, obeys the Law of Macro-Parsimony: "don't use > defmacro," namely, "where defn will suffice;" Clojure, on the other > hand, is macro-liberal. > > In other words, everyone seems to prefer e.g. `(defmacro foo [vars & > bo

Re: java this keyword ?

2011-12-20 Thread Cedric Greevey
On Wed, Dec 21, 2011 at 1:42 AM, Antonio Recio wrote: > I would like to convert a java code to clojure that contains the word > "this", but I don't know how to. > > Java: > boxWidget.AddObserver("InteractionEvent", this, "myCallback"); > > Clojure: > (doto boxWidget (.AddObserver "InteractionEvent

Re: IllegalArgumentException Parameter declaration should be a vector ?

2011-12-20 Thread Cedric Greevey
On Wed, Dec 21, 2011 at 12:16 AM, Antonio Recio wrote: > Whith this code: >   (defn myCallback >   (def t (vtk.vtkTransform.)) >   (doto boxWidget >     (.GetTransform t) >     (-> (.GetProp3D) (.SetUserTransform t)) >     )) > > I get this error. Why? > IllegalArgumentExceptio

Re: How to create an alias of clojure.lang.RT/loadLibrary?

2011-12-20 Thread Cedric Greevey
On Tue, Dec 20, 2011 at 6:35 PM, Sean Corfield wrote: > On Tue, Dec 20, 2011 at 1:04 PM, Aaron Cohen wrote: >> The classloader that loaded RT is the one that is used by the loadLibrary >> call in RT.loadLibrary. >> >> If you call System/loadLibrary from a clojure form, it will be an instance >> o

Re: Could be my favourite improvement in 1.4

2011-12-20 Thread Cedric Greevey
On Tue, Dec 20, 2011 at 2:05 AM, Alan Malloy wrote: > On Dec 19, 9:25 pm, Phil Hagelberg wrote: >> JSON as readable Clojure was discussed and shot down a while back, albeit >> with a weirder >> implementation:http://groups.google.com/group/clojure-dev/browse_thread/thread/5b066... >> idea of col

Re: defrecord based on runtime metadata?

2011-12-18 Thread Cedric Greevey
On Sun, Dec 18, 2011 at 2:56 PM, Bill Robertson wrote: > I'm trying to define records based on meta data read in at runtime, > and I'm attempting to write a function that extracts name and attrs > and passes them to defrecord, but I don't understand how to > dynamically create the symbol for the r

Re: unquote-splicing when calling macro

2011-12-17 Thread Cedric Greevey
On Sat, Dec 17, 2011 at 11:08 AM, Baishampayan Ghose wrote: >> This may sound a bit weird, but can I "unquote-splice" something when >> calling a macro. Here's an attempt to do this with hiccup: >> >> (defn get-header >>   [[:link {:type "text/css" ...}] >>    [:script {:type "text/javascript" ...

Re: London Incanter Hack Day tomorrow: CANCELLED

2011-12-17 Thread Cedric Greevey
On Sat, Dec 17, 2011 at 11:55 AM, Ben Evans wrote: > Hi, > > There would normally be an Incanter Hack Day taking place tomorrow. > > However, our usual venue (the Royal Festival Hall) has had bad wifi > the last couple of times, and we don't feel that it's fair to try to > run a Hack Day under tho

Re: Bug with 1.3 primitive function return value hinting.

2011-12-16 Thread Cedric Greevey
On Fri, Dec 16, 2011 at 8:20 AM, Meikel Brandmeyer wrote: > Hi, > > Am 16.12.2011 um 12:17 schrieb Cedric Greevey: > >> You *already* can't change the type signature of an optimized function >> without needing to recompile its callers. > > But once you settle

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

2011-12-16 Thread Cedric Greevey
2011/12/16 jaime : > Yes this is a good point, but how can I avoid this blowing up problem > if I'm not handling a single variable (just as the code in my last > post)? Someone else indicated that just using pr-str and using the *print-length* and *print-level* vars can avoid the problem. Or, you

Re: Bug with 1.3 primitive function return value hinting.

2011-12-16 Thread Cedric Greevey
On Fri, Dec 16, 2011 at 4: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,

Re: Bug with 1.3 primitive function return value hinting.

2011-12-15 Thread Cedric Greevey
On Thu, Dec 15, 2011 at 10:13 PM, David Nolen wrote: > Nobody wants map-longs. We have lovely abstractions like map / filter / > reduce, we have primitive fns, we have collections which can hold > primitives, we have type hints. > > What I'd like to see is that by adding one single annotation to t

Re: Bug with 1.3 primitive function return value hinting.

2011-12-15 Thread Cedric Greevey
On Thu, Dec 15, 2011 at 9:31 PM, David Nolen wrote: > On Thu, Dec 15, 2011 at 9:23 PM, Cedric Greevey wrote: >> There is no possibility of "high performance higher order usage", >> because primitives are boxed inside of collections. Unless you >> proliferate in

Re: Bug with 1.3 primitive function return value hinting.

2011-12-15 Thread Cedric Greevey
On Thu, Dec 15, 2011 at 8:56 PM, David Nolen wrote: > On Thu, Dec 15, 2011 at 8:16 PM, Cedric Greevey wrote: >> >> public class MangledName implements IFn { >>    public Object invoke () { // unoptimized zero-arg version or arity >> throw goes here } >>

Re: Bug with 1.3 primitive function return value hinting.

2011-12-15 Thread Cedric Greevey
On Thu, Dec 15, 2011 at 8:47 PM, Softaddicts wrote: > Your approach requires some lifting both in the runtime and the compiler. I beg your pardon? > Why not sign a CA, implement it and submit a patch and supporting runtime > data ? Sounds like a lot of hoops to jump through. The direct-primiti

Re: Bug with 1.3 primitive function return value hinting.

2011-12-15 Thread Cedric Greevey
On Thu, Dec 15, 2011 at 8:32 PM, Softaddicts wrote: > It's not "silly", it's the fastest way to dispatch fn calls... Only calls with more than 20 arguments (or via "apply") would need to be dispatched specially. -- You received this message because you are subscribed to the Google Groups "Cloju

Re: Bug with 1.3 primitive function return value hinting.

2011-12-15 Thread Cedric Greevey
On Thu, Dec 15, 2011 at 8:05 PM, Softaddicts wrote: > From a JVM perspective, f(& arglist) is a one arg function. > Try defining a fn with more than 20 args and you will get the > "can't specify more than 20 arguments" error. > This is the maximum supported by the Clojure runtime for "non-opti

Re: Bug with 1.3 primitive function return value hinting.

2011-12-15 Thread Cedric Greevey
On Thu, Dec 15, 2011 at 7:48 PM, David Nolen wrote: > On Thu, Dec 15, 2011 at 7:43 PM, Cedric Greevey wrote: >> >> In that case, I don't see the need for the interface in the >> non-higher-order case. It could just create a Java method of some >> class that imple

Re: Bug with 1.3 primitive function return value hinting.

2011-12-15 Thread Cedric Greevey
On Thu, Dec 15, 2011 at 7:29 PM, David Nolen wrote: > On Thu, Dec 15, 2011 at 7:14 PM, Cedric Greevey wrote: >> >> For helper fns, it's unlikely to be necessary to use the function >> widely in generic contexts, i.e. in a first-class manner, right? > > fns with

Re: Bug with 1.3 primitive function return value hinting.

2011-12-15 Thread Cedric Greevey
On Thu, Dec 15, 2011 at 6:51 PM, Softaddicts wrote: > Hi Cedric, > > Your statement " A limitation on primitive arguments simply cannot be > applicable to a function with no primitive arguments" does not stand It is true by axiom. Either the limitation is not actually a limitation "on primitive a

Re: Bug with 1.3 primitive function return value hinting.

2011-12-15 Thread Cedric Greevey
On Thu, Dec 15, 2011 at 6:33 PM, David Nolen wrote: > On Thu, Dec 15, 2011 at 6:19 PM, Cedric Greevey wrote: >> >> I don't see any logical reason why a function taking only >> non-primitive arguments cannot have a primitive return value. > > > You need a JVM

Re: Bug with 1.3 primitive function return value hinting.

2011-12-15 Thread Cedric Greevey
On Thu, Dec 15, 2011 at 6:05 PM, David Nolen wrote: > On Thu, Dec 15, 2011 at 6:01 PM, Cedric Greevey wrote: >> >> On Thu, Dec 15, 2011 at 5:59 PM, David Nolen >> wrote: >> > On Thu, Dec 15, 2011 at 5:53 PM, Cedric Greevey >> > wrote: >> >

Re: Bug with 1.3 primitive function return value hinting.

2011-12-15 Thread Cedric Greevey
On Thu, Dec 15, 2011 at 5:59 PM, David Nolen wrote: > On Thu, Dec 15, 2011 at 5:53 PM, Cedric Greevey wrote: >> #> primitives support only 4 or fewer args, >> >> But the function isn't *taking* primitives. It's only *returning* a >> primitive, after t

Re: Bug with 1.3 primitive function return value hinting.

2011-12-15 Thread Cedric Greevey
And a related bug/quirk: I had had (defn- remm "Remainder of a modulo b; unlike (rem a b) result is in [0,b) even if a is negative." ([a b] (let [r (rem a b)] (if (< r 0) (+ r b) r and evaluated (defn- remm "Remainder of a modulo b; unlike (rem a b) result

Bug with 1.3 primitive function return value hinting.

2011-12-15 Thread Cedric Greevey
(defn dist "Shortest distance between x,y and x2,y2 in toroidal space of dimensions w,h. Input coordinates should be in range (0,0)-(w,h). For instance, will give 1.414... if x,y = (0,0) and x2,y2 = (w-1,h-1), as these are diagonally adjacent." ([x y x2 y2 w h] (let [x2s [(- x2 w)

Re: my first attempt at a macro returns form wrapped in clojure.core/fn

2011-12-15 Thread Cedric Greevey
On Thu, Dec 15, 2011 at 2:16 PM, Alan Malloy wrote: > FWIW, much safer is > > (defmacro dc >  [sql-cmd] >  `(sql/with-connection db >     ~sql-cmd)) > > If you use the version with (list) and plain-quoting of the first two > items, then the namespace resolution is very fragile: it will only > work

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

2011-12-15 Thread Cedric Greevey
On Thu, Dec 15, 2011 at 1:54 PM, Alan Malloy wrote: > This will print all the debug information at compile time, which is > usually not what you want. I have a little macro I use called ?, which > looks like: > > (defmacro ? [x] >  `(let [x# ~x] >     (prn '~x '~'is x#) >     x#)) > > You could ad

Re: Lazy-seq of a binary file

2011-12-15 Thread Cedric Greevey
On Wed, Dec 14, 2011 at 11:47 PM, Simone Mosciatti wrote: > Ok thank you so much, i got it. > > Thanks again ;-) You're welcome. -- 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

Re: my first attempt at a macro returns form wrapped in clojure.core/fn

2011-12-15 Thread Cedric Greevey
On Thu, Dec 15, 2011 at 1:14 PM, Peter Buckley wrote: > TL;DR I have an extra clojure.core/fn wrapped around the form I want > returned from my macro. This is my first macro and I'm not sure what's > wrong, even though the macro "works." ... > (defmacro dc >  [sql-cmd] >  (list 'sql/with-connect

Re: Lazy-seq of a binary file

2011-12-14 Thread Cedric Greevey
On Wed, Dec 14, 2011 at 12:04 AM, Simone Mosciatti wrote: > Thank you so much, just one last thing, why you use a char-array ? Reader returns chars. > If I want use a byte-array, and no map all the whole sequence ? Use an InputStream rather than a reader if you're reading binary files (or text

Re: Opposite function to cons, but in terms of construction, not destruction.

2011-12-14 Thread Cedric Greevey
On Wed, Dec 14, 2011 at 3:12 AM, Alan Malloy wrote: > On Dec 13, 8:37 pm, Cedric Greevey wrote: >> On Tue, Dec 13, 2011 at 11:25 PM, Alan Malloy wrote: >> > On Dec 13, 7:56 pm, Stephen Compall wrote: >> >> On Tue, 2011-12-13 at 16:28 -0800, Alan Malloy wrote: &

Re: Lazy-seq of a binary file

2011-12-13 Thread Cedric Greevey
On Tue, Dec 13, 2011 at 11:33 PM, Simone Mosciatti wrote: > Where by now: > (defn lazy-reader [fl] >     (assert ...) >     (lazy-seq >         (cons (.read fl) (lazy-reader fl > > The first one ? Er, buffering of the I/O is probably preferable, but that would probably work OK in many cases.

Re: Opposite function to cons, but in terms of construction, not destruction.

2011-12-13 Thread Cedric Greevey
On Tue, Dec 13, 2011 at 11:25 PM, Alan Malloy wrote: > On Dec 13, 7:56 pm, Stephen Compall wrote: >> On Tue, 2011-12-13 at 16:28 -0800, Alan Malloy wrote: >> > As you can see, only as many elements are realized as are needed to >> > satisfy the user's request. >> >> Yes, in the expression (conr (

Re: Lazy-seq of a binary file

2011-12-13 Thread Cedric Greevey
On Tue, Dec 13, 2011 at 11:12 PM, Simone Mosciatti wrote: > Ok, now by now i think to have understand... > > To do right, I should build a macro similar to let where I pass the > filename and after execute the body close the stream, right ? Easier to just use the pre-existing one: with-open. Som

Re: Lazy-seq of a binary file

2011-12-13 Thread Cedric Greevey
On Tue, Dec 13, 2011 at 10:14 PM, Simone Mosciatti wrote: > No, I'm sure to not use all the sequence, so I will follow your second > advice, but... > > Cause of my non-perfect english I've not really understand the last > part. >  Who is the caller ? >  You suggest something like this: > > (let [f

Re: bug in clojure.walk in 1.3

2011-12-13 Thread Cedric Greevey
On Tue, Dec 13, 2011 at 2:51 PM, Alan Malloy wrote: > On Dec 13, 11:36 am, Stuart Sierra > wrote: >> It's not clojure.walk, it's bean: >> >> user=> (empty (bean "hi")) >> AbstractMethodError >> clojure.lang.APersistentMap.empty()Lclojure/lang/IPersistentCollection; >> clojure.core.proxy$clojure.l

Re: Lazy-seq of a binary file

2011-12-12 Thread Cedric Greevey
You also probably want more efficiency. Try something closer to: (defn lazy-reader [filename] (let [rd (fn [rdr] (let [buf (char-array 4096) n (.read rdr buf 0 4096)] (condp == n -1 (.close rdr) 0 (recur rdr)

Re: Surprising behavior with clojure.core/int (and probably other primitive integer functions)

2011-12-06 Thread Cedric Greevey
Thanks. I think this is an area where there will hopefully be a bit more polish in 1.4. Particularly regarding cleanly wrapping code in unchecked on/off ... though a function that just amounts to #(.intValue ^Number %) would save everyone writing such closures over and over again when they need a n

Surprising behavior with clojure.core/int (and probably other primitive integer functions)

2011-12-06 Thread Cedric Greevey
user=> (binding [*unchecked-math* true] (map int [33 77 0x])) # The cause of this: (defn int "Coerce to int" { :inline (fn [x] `(. clojure.lang.RT (~(if *unchecked-math* 'uncheckedIntCast 'intCast) ~x))) :added "1.0"} [x] (. clojure.lang.RT (intCast x))) The inline and non-i

<    1   2   3   4   5   6