Aw: Odd "error" using CCW.

2011-05-29 Thread Meikel Brandmeyer
Hi,

you might want to ask this on the counterclockwise mailing list: 
https://groups.google.com/forum/#!forum/clojuredev-devel

That help Laurent to keep track of such issues.

Sincerely
Meikel

-- 
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

Re: Radically simplified Emacs and SLIME setup

2011-05-29 Thread László Török
Then you might wanna double check whether you have the latest version (of
emacs-starter-kit), as it worked for me with a week old snapshot. (Im on
Mac, running Aquamacs).

2011/5/30 Mark Engelberg 

> On Sun, May 29, 2011 at 10:06 PM, László Török  wrote:
> > Heh, yeah that marmelade was a funny one, I spent a few hours figuring
> what
> > goes where.
> >
> > I suggest you download emacs-starter-kit from Phil's github repo, that
> has
> > the necessary configuration for marmelade too.
> >
> > Then proceed with installing clojure-mode.
>
> I did all that once (downloading Phil's emacs-starter-kit) a long time
> ago.  I just can't seem to get it all to download the newest version
> of clojure-mode.  For example, when I do package-list-packages it
> still shows 1.7.1.  Any pointers?
>
> Thanks,
>
> Mark
>
> --
> 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
>



-- 
László Török

Skype: laczoka2000
Twitter: @laczoka

-- 
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

Re: Radically simplified Emacs and SLIME setup

2011-05-29 Thread Mark Engelberg
On Sun, May 29, 2011 at 10:06 PM, László Török  wrote:
> Heh, yeah that marmelade was a funny one, I spent a few hours figuring what
> goes where.
>
> I suggest you download emacs-starter-kit from Phil's github repo, that has
> the necessary configuration for marmelade too.
>
> Then proceed with installing clojure-mode.

I did all that once (downloading Phil's emacs-starter-kit) a long time
ago.  I just can't seem to get it all to download the newest version
of clojure-mode.  For example, when I do package-list-packages it
still shows 1.7.1.  Any pointers?

Thanks,

Mark

-- 
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


Re: Radically simplified Emacs and SLIME setup

2011-05-29 Thread László Török
Heh, yeah that marmelade was a funny one, I spent a few hours figuring what
goes where.

I suggest you download emacs-starter-kit from Phil's github repo, that has
the necessary configuration for marmelade too.

Then proceed with installing clojure-mode.

Las

sent from my mobile device

On May 30, 2011 4:53 AM, "Mark Engelberg"  wrote:
> I need more details about how to install the current version of
> clojure-mode. When I do alt-x package-install and type clojure-mode I
> get a bunch of messages that it is compiling clojure-mode 1.7.1.
>
> The website said to install clojure-mode via marmalade, but it's not
> at all clear to me what marmalade actually does (the website for
> marmalade gives brief instructions about how to install marmalade, but
> nothing about how to use it to install something else).
>
> Thanks in advance,
>
> Mark
>
> --
> 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

-- 
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

Re: difference between Composite Form & Special Form

2011-05-29 Thread iamcreasy
> Sort of. You can create a macro with defmacro, which like a special
> form controls the evaluation of its arguments instead of the arguments
> being evaluated first and the function only getting the results.
> Things like -> and defn are macros:

That means, the difference of composite form and special form, is the
order / sequence of evaluation of arguments? right?
Composite form can be a function(list) or some other supported data
structures(Vector, map and set). Special form which looks a lot like a
funciton, is NOT a funciton / list / composite form at all.

This also means, what is written on the book about special form
"Special forms are a particular type of composite form. For most
purposes, they are used very similarly to
a function call. The difference is that the first form of a special
form is not a function defined
somewhere, but a special system form that’s built into Clojure."

is badly written or wrong, right?

Its not about being special form as a composite form, they are
different to begin with.
Its not about being 'built into clojure', its about how they work.

> 5. (foo bar baz) with foo not a special operator: the subform foo is
> looked up at compile time and if it's a macro, macro expansion is
> performed. The transformed code is then evaluated per these rules.

I didn't understand this one.Is it about user defined function?

> 6. (foo bar baz) with foo not a special operator or a macro. At
> compile time, code is generated to evaluate foo, bar, and baz at
> runtime and then apply foo as a function to the arguments bar and baz.

I didn't understand this point too. An example would help.

> (def bar baz)   bar var interned  baz eval'd, bar set
> (macro x y) macro is expanded expansion is eval'd

Arn't they same? def is written withing clojure and when needed its
expanded.

> 'def is definitely a symbol.

If def is a symbol then it should evaluated to somthing?like, when I
write 'print' and press return key, I get

#

but, in case of def, i get the following 'Error',

#

Isn't this concludes def is not a symbol cause its returning an error.




>From you explanation what i got that, built in macros are called
special form and I can also create my custom macros, which will be
called special forms. is it right?

Your second post is a little over my head :s


On May 26, 8:58 am, Ken Wesson  wrote:
> On Wed, May 25, 2011 at 10:15 PM, iamcreasy  wrote:
> > 1st question,
> > Is the form word is a typo here? Isn't the word will be item? If not,
> > is def a form? That means, this code contains 3 forms. :-s
>
> Technically, anything that can be evaluated is a form. A composite
> form is something like a literal list, vector, set, or map. The
> literal list case is treated as an operator and arguments; the other
> three just evaluate to vectors, sets, or maps, respectively, whose
> members are the evaluations of the nested forms, so:
>
> +                  => the + function
> (+ 1 2)            => 3
> [+ 1 2]            => a vector of the + function, 1, and 2.
> [(+ 1 2)]          => [3]
> #{(+ 1 2) 4}       => #{3 4}
> {:a (+ 1 2)}       => {:a 3}
>
> > 2nd question,
> > Is a composite form is a special form only when, the first item of a
> > list is something that is only predefined withing Clojure? If yes,
> > then is it possible to create custom special form?
>
> Sort of. You can create a macro with defmacro, which like a special
> form controls the evaluation of its arguments instead of the arguments
> being evaluated first and the function only getting the results.
> Things like -> and defn are macros:
>
> (-> 3
>   (+ 1)
>   (* 2))
>
> adds 1 to 3, then doubles, yielding 8. This couldn't work with a
> function, as it would get arguments 3, 1, and 2 as (+ 1) would
> evaluate, first, to 1, and (* 2) to 2. It wouldn't know what to do
> with 3, 1, or 2 -- whether to add 1 and then multiply by 2, or
> subtract 1 and then add 2, or what. The macro, however, operates on
> the *forms* and gets 3, (+ 1), and (* 2) and combines the first two
> into (+ 3 1) and that and the third into (* (+ 3 1) 2) by inserting
> each form into the next one after the operator and before everything
> else.
>
> (defn foo [a b] (+ (* a a) (* b b)))
>
> also cannot be a normal function call. If it were there would be
> several errors: foo undefined (most likely), also a and b undefined,
> so the first argument foo could not be evaluated, nor could the second
> [a b], nor could the third (+ (* a a) (* b b)). But instead it works
> to generate a function definition. It's a macro that expands to a (def
> ...) form, in fact.
>
> > But, at the beginning the writer said, there are four basic varieties
> > of forms.
>
> > 1. Literal,
> > 2. Symbol,
> > 3. Composite form and
> > 4. Special form.
>
> I'd say it's a bit more complicated than that. We have six things that
> are evaluated somewhat differently:
>
> 1. nil, true, false, numbers, strings, regexps, keywords ... evaluate
> to themselves.
>

Re: difference between Composite Form & Special Form

2011-05-29 Thread iamcreasy
> Sort of. You can create a macro with defmacro, which like a special
> form controls the evaluation of its arguments instead of the arguments
> being evaluated first and the function only getting the results.
> Things like -> and defn are macros:

That means, the difference of composite form and special form, is the
order / sequence of evaluation of arguments? right?
Composite form can be a function(list) or some other supported data
structures(Vector, map and set). Special form which looks a lot like a
funciton, is NOT a funciton / list / composite form at all.

This also means, what is written on the book about special form
"Special forms are a particular type of composite form. For most
purposes, they are used very similarly to
a function call. The difference is that the first form of a special
form is not a function defined
somewhere, but a special system form that’s built into Clojure."

is badly written or wrong, right?

Its not about being special form as a composite form, they are
different to begin with.
Its not about being 'built into clojure', its about how they work.

> 5. (foo bar baz) with foo not a special operator: the subform foo is
> looked up at compile time and if it's a macro, macro expansion is
> performed. The transformed code is then evaluated per these rules.

I didn't understand this one.Is it about user defined function?

> 6. (foo bar baz) with foo not a special operator or a macro. At
> compile time, code is generated to evaluate foo, bar, and baz at
> runtime and then apply foo as a function to the arguments bar and baz.

I didn't understand this point too. An example would help.

> (def bar baz)   bar var interned  baz eval'd, bar set
> (macro x y) macro is expanded expansion is eval'd

Arn't they same? def is written withing clojure and when needed its
expanded.

> 'def is definitely a symbol.

If def is a symbol then it should evaluated to somthing?like, when I
write 'print' and press return key, I get

#

but, in case of def, i get the following 'Error',

#

Isn't this concludes def is not a symbol cause its returning an error.




>From you explanation what i got that, built in macros are called
special form and I can also create my custom macros, which will be
called special forms. is it right?

Your second post is a little over my head :s


On May 26, 8:58 am, Ken Wesson  wrote:
> On Wed, May 25, 2011 at 10:15 PM, iamcreasy  wrote:
> > 1st question,
> > Is the form word is a typo here? Isn't the word will be item? If not,
> > is def a form? That means, this code contains 3 forms. :-s
>
> Technically, anything that can be evaluated is a form. A composite
> form is something like a literal list, vector, set, or map. The
> literal list case is treated as an operator and arguments; the other
> three just evaluate to vectors, sets, or maps, respectively, whose
> members are the evaluations of the nested forms, so:
>
> +                  => the + function
> (+ 1 2)            => 3
> [+ 1 2]            => a vector of the + function, 1, and 2.
> [(+ 1 2)]          => [3]
> #{(+ 1 2) 4}       => #{3 4}
> {:a (+ 1 2)}       => {:a 3}
>
> > 2nd question,
> > Is a composite form is a special form only when, the first item of a
> > list is something that is only predefined withing Clojure? If yes,
> > then is it possible to create custom special form?
>
> Sort of. You can create a macro with defmacro, which like a special
> form controls the evaluation of its arguments instead of the arguments
> being evaluated first and the function only getting the results.
> Things like -> and defn are macros:
>
> (-> 3
>   (+ 1)
>   (* 2))
>
> adds 1 to 3, then doubles, yielding 8. This couldn't work with a
> function, as it would get arguments 3, 1, and 2 as (+ 1) would
> evaluate, first, to 1, and (* 2) to 2. It wouldn't know what to do
> with 3, 1, or 2 -- whether to add 1 and then multiply by 2, or
> subtract 1 and then add 2, or what. The macro, however, operates on
> the *forms* and gets 3, (+ 1), and (* 2) and combines the first two
> into (+ 3 1) and that and the third into (* (+ 3 1) 2) by inserting
> each form into the next one after the operator and before everything
> else.
>
> (defn foo [a b] (+ (* a a) (* b b)))
>
> also cannot be a normal function call. If it were there would be
> several errors: foo undefined (most likely), also a and b undefined,
> so the first argument foo could not be evaluated, nor could the second
> [a b], nor could the third (+ (* a a) (* b b)). But instead it works
> to generate a function definition. It's a macro that expands to a (def
> ...) form, in fact.
>
> > But, at the beginning the writer said, there are four basic varieties
> > of forms.
>
> > 1. Literal,
> > 2. Symbol,
> > 3. Composite form and
> > 4. Special form.
>
> I'd say it's a bit more complicated than that. We have six things that
> are evaluated somewhat differently:
>
> 1. nil, true, false, numbers, strings, regexps, keywords ... evaluate
> to themselves.
>

Dependencies with native components

2011-05-29 Thread Phil Hagelberg
I started a thread on the Leiningen mailing list about improving
support for dependencies with native components, but I realized I
should have put it on the main Clojure list instead for a wider
audience: 
http://groups.google.com/group/leiningen/browse_thread/thread/11e225cdea343176

If you maintain or use a library that includes native code then please
take a look at the proposal; your input is welcome.

-Phil

-- 
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


Re: Radically simplified Emacs and SLIME setup

2011-05-29 Thread Mark Engelberg
I need more details about how to install the current version of
clojure-mode.  When I do alt-x package-install and type clojure-mode I
get a bunch of messages that it is compiling clojure-mode 1.7.1.

The website said to install clojure-mode via marmalade, but it's not
at all clear to me what marmalade actually does (the website for
marmalade gives brief instructions about how to install marmalade, but
nothing about how to use it to install something else).

Thanks in advance,

Mark

-- 
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


Writing Android Apps in Clojure

2011-05-29 Thread Brian Rowe
Hi, I've seen that one of the biggest speed bumps on the path to
delivering an Android application written in Clojure is app startup
time.

Has anyone tried writing the application's initial activity in pure
java and delegating the loading of clojure to a service?  Perhaps the
service could send a broadcast when it is finished loading. At that
point the activity could enable code paths that jump into Clojure
code.

I'm not completely familiar with how libraries get loaded and
initialized in Dalvik.  This may not even bee possible, or perhaps it
would require the service to be an out of process service.

Anyhow, I would be interested to know if anyone has tried this.

Thanks!

-- 
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


Re: Idiomatic use of records vs. maps

2011-05-29 Thread Ken Wesson
On Sun, May 29, 2011 at 8:56 PM, James Reeves  wrote:
> The documentation on records seems to indicate that they be used in
> place of structs, but is there any advantage to using a record if no
> protocols are assigned to it?

Access to a record's in-definition members should be faster than
access to arbitrary keys in a map, but that's it if no protocols are
used.

> For example, I've defined a TcpServer record as part of a library I'm
> developing:
>
>  (defrecord TcpServer
>    [port
>     host
>     backlog
>     handler
>     socket
>     connections])
>
>  (defn tcp-server [& {:as options}]
>    {:pre [(:port options) (:handler options)]}
>    (TcpServer.
>     (:port options)
>     (:host options "127.0.0.1")
>     (:backlog options 50)
>     (:handler options)
>     (atom nil)
>     (atom #{})))
>
> Is this idiomatic Clojure, or should I just use a map instead:
>
>  (defn tcp-server [& {:as options}]
>    (merge
>     {:host "127.0.0.1"
>      :backlog 50
>      :socket (atom nil)
>      :connections (atom #{})
>     options))

I don't think either is non-idiomatic, but I'd probably just use the
map. It's shorter and simpler code, more widely interoperable with
other Clojure facilities, and the member access speedup using a record
is unlikely to matter much in code that is blocked on I/O nearly all
of the time anyway. If you were using it in CPU-intensive work, e.g. a
complex number datatype in heavy number crunching, then the speedup
would matter (although in that specific instance a 1.3
primitive-double vector of length 2 would probably beat a record for
speed unless records or deftypes can have unboxed primitive fields and
you can access these without boxing in 1.3).

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

-- 
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


Idiomatic use of records vs. maps

2011-05-29 Thread James Reeves
The documentation on records seems to indicate that they be used in
place of structs, but is there any advantage to using a record if no
protocols are assigned to it?

For example, I've defined a TcpServer record as part of a library I'm
developing:

  (defrecord TcpServer
[port
 host
 backlog
 handler
 socket
 connections])

  (defn tcp-server [& {:as options}]
{:pre [(:port options) (:handler options)]}
(TcpServer.
 (:port options)
 (:host options "127.0.0.1")
 (:backlog options 50)
 (:handler options)
 (atom nil)
 (atom #{})))

Is this idiomatic Clojure, or should I just use a map instead:

  (defn tcp-server [& {:as options}]
(merge
 {:host "127.0.0.1"
  :backlog 50
  :socket (atom nil)
  :connections (atom #{})
 options))

- James

-- 
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


Odd "error" using CCW.

2011-05-29 Thread Ken Wesson
I get the following in "problems" in CCW when opening a particular
Clojure project:

Unable to resolve symbol: => in this context sandbox.clj
/sandbox/src line 1 Clojure Compilation Problem

The line in question is just this:

(ns sandbox)

Error, my left nostril. Of course, perhaps CCW is seeing the macro
expansion, and it contains a => somewhere, and it's interpreted
specially by more macros, but the editor isn't smart enough to realize
that and assumes it should resolve to a global Var, but:

=> (macroexpand '(ns sandbox))
(do (clojure.core/in-ns (quote sandbox))
  (clojure.core/with-loading-context
(clojure.core/refer (quote clojure.core

There's nothing in here that resembles => except for the REPL prompt I
typed the macroexpand form at. I'd think maybe it was even mistaking a
REPL prompt for a symbol in need of resolving, except it appears
before any REPL is even started.

It doesn't seem to actually break anything, though, except possibly
AOT compilation, which I don't need for my sandbox "project" (random
code snippets and experimentation sandbox). Unless I see this block
AOT compilation of something that actually needs it I'm classing it as
cosmetic. (Even if it did stop in-Eclipse AOT compilation, I'd only be
one "lein uberjar" away from deployment anyway, so even then it isn't
a showstopper.)

Don't know if the problem is in CCW, or the particular version of the
Clojure compiler that installed with it, or both. The Clojure version
at the CCW REPL reports its identity thusly:

=> *clojure-version*
{:major 1, :minor 2, :incremental 0, :qualifier ""}

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

-- 
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


Re: aset and shorts, aset vs aset-int

2011-05-29 Thread Alan Malloy
More efficient than vectors of non-primitives, one imagines. Or, more
efficient than primitive vectors before 1.3 (I'm not sure if primitive
vectors exist in 1.2).

On May 29, 2:26 pm, Ken Wesson  wrote:
> On Sun, May 29, 2011 at 1:39 PM, David Nolen  wrote:
> > Vectors of primitives are more efficient,
>
> [1]
>
> > but there's work to be done for them to approach Java
> > arrays in perf.
>
> [2]
>
> Aren't your statements [1] and [2] contradictory? Did you mean "more
> idiomatic" perhaps in [1], or "more functional"?
>
> --
> Protege: What is this seething mass of parentheses?!
> Master: Your father's Lisp REPL. This is the language of a true
> hacker. Not as clumsy or random as C++; a language for a more
> civilized age.

-- 
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


Re: aset and shorts, aset vs aset-int

2011-05-29 Thread Jonathan Fischer Friberg
I think he meant that vectors of primitives are more efficient than normal
vectors.

Jonathan

On Sun, May 29, 2011 at 11:26 PM, Ken Wesson  wrote:

> On Sun, May 29, 2011 at 1:39 PM, David Nolen 
> wrote:
> > Vectors of primitives are more efficient,
>
> [1]
>
> > but there's work to be done for them to approach Java
> > arrays in perf.
>
> [2]
>
> Aren't your statements [1] and [2] contradictory? Did you mean "more
> idiomatic" perhaps in [1], or "more functional"?
>
> --
> Protege: What is this seething mass of parentheses?!
> Master: Your father's Lisp REPL. This is the language of a true
> hacker. Not as clumsy or random as C++; a language for a more
> civilized age.
>
> --
> 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
>

-- 
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

Re: aset and shorts, aset vs aset-int

2011-05-29 Thread Ken Wesson
On Sun, May 29, 2011 at 1:39 PM, David Nolen  wrote:
> Vectors of primitives are more efficient,

[1]

> but there's work to be done for them to approach Java
> arrays in perf.

[2]

Aren't your statements [1] and [2] contradictory? Did you mean "more
idiomatic" perhaps in [1], or "more functional"?

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

-- 
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


Re: aset and shorts, aset vs aset-int

2011-05-29 Thread David Nolen
On Sun, May 29, 2011 at 4:35 PM, bOR_  wrote:

> Thanks for the help, appreciated! It helped me figuring out where exactly
> things go haywire.
>
> This works:
> user> (let [^ints as (make-array Integer/TYPE 10)] (aset as 0 (+ (aget as
> 1) (aget as 2
>
> 0
>
> and this breaks
>
> user> (let [^shorts as (make-array Short/TYPE 10)] (aset as 0 (+ (aget as
> 1) (aget as 2
> No matching method found: aset
>
> What am I doing wrong?
>

You need to cast to short.

(aset as 0 (short (+ (aget as 1) (aget as 2

David

-- 
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

Re: aset and shorts, aset vs aset-int

2011-05-29 Thread bOR_
Thanks for the help, appreciated! It helped me figuring out where exactly 
things go haywire.

This works:
user> (let [^ints as (make-array Integer/TYPE 10)] (aset as 0 (+ (aget as 1) 
(aget as 2   
  
0 

and this breaks

user> (let [^shorts as (make-array Short/TYPE 10)] (aset as 0 (+ (aget as 1) 
(aget as 2 
No matching method found: aset   

What am I doing wrong?

-- 
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

Re: Writing conditions on geometric coordinates

2011-05-29 Thread Andreas Liljeqvist
Not sure if I understand your problem.

Is it the verbosity of extracting coordinates? (rect-one :x1)

Or is the problem with increasing the dimensionality?

Anyhow I would define the types as following:

(def point [1 2 3])
(def rect [point point])

(defn point-in-rect? [p [[r1 r2]]]
  (every? true? (map <= r1 p r2)))

(defn overlap-rect? [a b]
  (or (some #(point-in-rect % a) b)
  (some #(point-in-rect % b) a)))

this should work for n-dimensions I think.

If you want to more closely follow your original code:

(with-destructured-rects rect-one rect-two
  (and
(>= r1x1 r2x0)
(>= r2x1 r1x0)))




2011/5/29 Brian Watkins 

> I often write code that deals with geometric coordinates and similar
> ordered n-tuples on homogenous bases.  Lots of times I face the
> situation where I want to write a condition that says, "if these two
> regions overlap, then do something," or "if this function is satisfied
> over an axis ax+by=c or over an axis bx+ay=c then do something."
>
> The issue is that the x and y (and z and z' ... ) coordinates are
> often interchangeable and the condition needs to be satisfied over any
> one of them or all of them.
>
> Here, for instance, is a check that two rectangles, rect-one and rect-
> two, with corners [:x0 :y0] and [:x1 :y1] overlap.  This is vastly
> simplified, of course.  I'm sure you can imagine that when the
> combinations of axes and desired conditions become more and more
> complex, the code gets more and more repetitive and awful.
>
> (and
>  (>= (rect-one :x1) (rect-two :x0))
>  (>= (rect-two :x1) (rect-one :x0))
>  (>= (rect-one :y1) (rect-two :y0))
>  (>= (rect-two :y1) (rect-one :y0)))
>
>
> Problem is that code is awful and repetitive.  I can shrink it in
> various one-off ways but I wonder if anyone has general advice or
> experience in writing a readable condition function.  I think it
> should be reduced with multiple axes substituted into a function
> somehow but I don't know a good idiom to make it clear.
>
> Maybe an experienced lisper or wise code craftsman can help me out.
>
> --
> 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

-- 
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

Re: :gen-class possibly missing a compile time check when extending abstract classes that implement interfaces

2011-05-29 Thread Sean Corfield
I also ran into this recently - doing the exact same thing (a log4j
appender). I was a bit surprised and I wonder if Clojure is
effectively generating abstract classes rather than concrete classes?
(Do we have no way to specify the difference? Is that only an artifact
of the Java compiler, not the JVM bytecode?)

As you say, the fix tends to be easy (read the class API docs and
implement the missing methods) but the behavior needs to be clearly
documented (on clojure.org) to help people avoid the problem I
think...

Sean

On Sun, May 29, 2011 at 7:04 AM, ckirkendall  wrote:
> I ran into this when creating a log4j appender in Clojure.  I extended
> the AppenderSkeleton, an abstract class. This abstract class
> implements Appender.  Appender defines two methods that don't appear
> in the AbstractSkeleton (requiresLayout & close).  I was able to
> compile the Clojure class, without the two methods in question, with
> no error.  I then threw a runtime exception when I tried to use the
> class.  The fix was easy but it seems this should probably be checked
> at compile time.

-- 
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


Re: aset and shorts, aset vs aset-int

2011-05-29 Thread David Nolen
On Sun, May 29, 2011 at 9:17 AM, bOR_  wrote:

> Is there something obvious I am missing when aset in clojure 1.3-alpha8
> won't work for shorts. aset-shorts does work, but way slower than I'd
> expect. There is also an order of magnitude difference in speed between aset
> ^ints and aset-int.
>
> I've looked at the source of amap (which was the first thing to give me
> problems with shorts), and from there came to writing the expanded amap
> macro out, and using aset-shorts rather than aset to get shorts working. I'm
> however stuck at looking at the source of aset and understanding how I can
> make that work with shorts.
>
> Related (now that I have the floor anyway), should I still be messing with
> java arrays in clojure 1.3, or would a vector of primitives be as fast?
>

aset- usage is not correct. Always use aset.

(let [^shorts as (make-array Short/TYPE 10)]
  (aset as 0 (short 1)))

Works fine.

Proper use of Java arrays is idiomatic for the forseeable future as far as I
can tell. Vectors of primitives are more efficient, but there's work to be
done for them to approach Java arrays in perf.

David

-- 
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

Re: fs and with-tempdir

2011-05-29 Thread David Jagoe
On 29 May 2011 16:40, Miki  wrote:
>
>> Cool, I'll clean up the code and submit it along with tests and docs.
>> While Im about it i may as well write the equivalent macro for tempfile.

I've submitted a bit bucket pull request with the changes. Never used
bit bucket before so not sure what the process is for you but let me
know if you'd just like me to attach a patch to the ticket instead.
I've written a single macro that can be used for both temporary files
and directories like this:

(fs/with-temp [f (fs/tempfile)]
  (do-stuff f))

(fs/with-temp [d (fs/tempdir)]
  (do-stuff d))

There are probably a couple of corner cases that I haven't dealt with
properly (e.g. I haven't checked that the result of evaluating the
second form in the binding vector can be deleted using fs/deltree.
That could cause some problems. Let me know what you think.


Cheers,
David

-- 
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


Re: fs and with-tempdir

2011-05-29 Thread Miki


> Cool, I'll clean up the code and submit it along with tests and docs. While 
> Im about it i may as well write the equivalent macro for tempfile.
>
Thanks! 

-- 
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

:gen-class possibly missing a compile time check when extending abstract classes that implement interfaces

2011-05-29 Thread ckirkendall
I ran into this when creating a log4j appender in Clojure.  I extended
the AppenderSkeleton, an abstract class. This abstract class
implements Appender.  Appender defines two methods that don't appear
in the AbstractSkeleton (requiresLayout & close).  I was able to
compile the Clojure class, without the two methods in question, with
no error.  I then threw a runtime exception when I tried to use the
class.  The fix was easy but it seems this should probably be checked
at compile time.

Clojure 1.2.1
Log4j 1.2.15

-- 
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


Re: Matrix operation (a la numpy)

2011-05-29 Thread bOR_
Incanter does. Works fine, but I'm not sure how fast it is.

-- 
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

aset and shorts, aset vs aset-int

2011-05-29 Thread bOR_
Is there something obvious I am missing when aset in clojure 1.3-alpha8 
won't work for shorts. aset-shorts does work, but way slower than I'd 
expect. There is also an order of magnitude difference in speed between aset 
^ints and aset-int.

I've looked at the source of amap (which was the first thing to give me 
problems with shorts), and from there came to writing the expanded amap 
macro out, and using aset-shorts rather than aset to get shorts working. I'm 
however stuck at looking at the source of aset and understanding how I can 
make that work with shorts.

Related (now that I have the floor anyway), should I still be messing with 
java arrays in clojure 1.3, or would a vector of primitives be as fast?

-- 
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