[ANN] Lime: An SMTP Client Library for Clojure

2012-01-25 Thread Jeremy Heiler
Hey all,

I've begun working on an SMTP client library[0] for Clojure that *does
not* depend on JavaMail. It is still in a very early stage of
development, but I hope to make it somewhat useful soon.

For my motivation, please check out my blog[1], which I will be
writing about the project as it matures.

[0] https://github.com/jeremyheiler/lime
[1] http://abitofclojure.com

Thanks,
//Jeremy

-- 
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: Adding primitive type hints to anonymous functions

2012-01-25 Thread Tassilo Horn
Cedric Greevey  writes:

Hi Cedric,

> Actually, on further testing, I'm not sure that (def ^{Double/TYPE}
> ...) is really working either, rather than boxing and then unboxing on
> each call:
>
> user=> (def ^{:tag Double/TYPE} b (fn [^double x] (+ x 0.5)))
> #'user/b
> user=> (defn c ^double [^double x] (+ x 0.5))
> #'user/c
> user=> (pt (b 0.1))
> :double
> user=> (pt (c 0.1))
> :double
>
> So far, so good? But:
>
> user=> (ancestors (.getClass b))
> #{java.util.concurrent.Callable clojure.lang.AFn clojure.lang.IObj
>   clojure.lang.IFn clojure.lang.IFn$DO clojure.lang.IMeta
>   java.lang.Object java.io.Serializable java.lang.Runnable
>   java.util.Comparator clojure.lang.AFunction clojure.lang.Fn}
>
> IFn$DO?

A Function that gets a double and returns an object, I think.  That
would support your claim that b doesn't return a primitive double,
although the Var is tagged.

> user=> (ancestors (.getClass c))
> #{java.util.concurrent.Callable clojure.lang.AFn clojure.lang.IObj
>   clojure.lang.IFn$DD clojure.lang.IFn clojure.lang.IMeta
>   java.lang.Object java.io.Serializable java.lang.Runnable
>   java.util.Comparator clojure.lang.AFunction clojure.lang.Fn}
>
> IFn$DD?

Gets and returns a primitive double.

> user=> (def d (fn ^double [^double x] (+ x 0.5)))
> #'user/d
> user=> (ancestors (.getClass d))
> #{java.util.concurrent.Callable clojure.lang.AFn clojure.lang.IObj
>   clojure.lang.IFn$DD clojure.lang.IFn clojure.lang.IMeta
>   java.lang.Object java.io.Serializable java.lang.Runnable
>   java.util.Comparator clojure.lang.AFunction clojure.lang.Fn}
>
> IFn$DD again here.

Hm, strange.  That means (to my best understanding), that the function
is correctly compiled to have a primitive version.  So maybe it's just
the call to anonymous functions that requires :arglists metadata to
correctly resolve the primitive version...

> This really *should* be simple. Therefore, there's a bug somewhere.
> But I'm not sure where. Compiler.java, most likely.

At least, it seems that (fn ^double [^double x] (+ x 0.5)) compiles to a
class supporting primitive, unboxed calls.

Bye,
Tassilo

-- 
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: Setting up Emacs to edit Clojure for Windows folks

2012-01-25 Thread nchurch
Cedric, you should append this to "The Unix-Hater's Handbook"I'm
not providing a link because I'm sure you already know it!

---Fellow Unix-hater, and Mac OS user (add flame suppressor here)

On Jan 25, 10:21 pm, Cedric Greevey  wrote:
> On Thu, Jan 26, 2012 at 12:25 AM, Sean Corfield  
> wrote:
> > On Wed, Jan 25, 2012 at 9:18 PM, Cedric Greevey  wrote:
> >> In other words, "ported software setup sucks!"? :)
>
> > That's not the conclusion I would have drawn... ;)
>
> >> Rather ironic, when the tendency, at least historically, has been for
> >> Windows (and Mac) to have superior usability when it comes to native
>
> > That depends on your point of view. I don't consider Windows
> > particularly usable - and I've used every version of it from 3.1 to
> > date... I'm sure we'll just agree to disagree on this one...
>
> I guess you're talking about a different kind of usability than I am.
>
> On the one hand, there's "it works properly and doesn't constantly
> crash". That's where Windows software has tended to be deficient (and,
> until recently, security).
>
> On the other hand, there's "setup for the typical configuration is
> point, click, reboot, done, and then you can sit down at it and use it
> with domain knowledge, general computer skills, and little else, and
> generally only need to consult some thick manual, or a cheat-sheet, or
> forums, or Wikipedia, or something when you're doing something unusual
> or advanced rather than common tasks such as cut, copy, and paste".
> That's where Unix software has tended to be deficient, often requiring
> complicated setup (though sometimes not) and almost always requiring a
> cheat-sheet, at least, to use it if you aren't a very regular,
> experienced user of the software. Frequently solution-space knowledge
> is even needed -- knowledge of compilers, terminology like "buffer",
> and so forth. Non-industry-standard bindings, mouse input semantics,
> selection and menu behavior (if there even are menus), and terminology
> abound in the typical case, up to and including various idiosyncratic
> neologisms specific to a single piece of software and not used by
> unrelated software with the same function (e.g. only emacs calls the
> clipboard or clipboards a "kill ring"; not only doesn't Notepad, nor
> does Editpad, Notepad++, vi, nano ...).
>
> Newer stuff, particularly designed for use with a package manager at
> install time and either Gnome or KDE, has tended to avoid these
> problems, though. Hence the "at least historically" above.
>
> Of course, this isn't limited purely to Unix. Before widespread
> networking and large market penetration of Windows PCs, idiosyncratic
> software and multiple attempts at standards proliferated on most
> platforms, excluding the Mac which came OOTB with a standard GUI
> toolkit. Old MS-DOS software is as guilty as vintage Unix software,
> with Wordstar and ancient versions of Lotus Notes (even for a while
> after it got a GUI!) being particularly infamous for requiring of
> users enormous feats of application-specific memorization and/or
> cheat-sheets.
>
> On the other hand, nobody uses those old pieces of MS-DOS software
> anymore. For some reason correspondingly old Unix software has a
> to-some-dismaying tendency to stay in use year after year. :)
>
> Actually, this may be a downside of open source. The likely reason is
> that the old MS-DOS software is proprietary, no longer maintained by
> the original developers, and in all likelihood no longer even exists
> as source, whereas the old Unix software is open source and people
> that got used to it stuck with it and even kept developing it
> themselves, so the software outlives generation after generation of
> hardware and is functionally immortal, but inertia keeps it full of
> legacy idiosyncrasies from before common idioms of computer
> interaction became standardized as a consequence of the computer
> becoming a common household tool rather than something only used at
> work, at school, and by geeks. So, open source seems to result in
> keeping old, pre-standardization things in use until the *users* die
> off rather than the hardware generation that begat it.
>
> On the positive side, nobody is forced at gunpoint to use any of it
> and standard-compliant alternatives that you can just sit at and use
> tend to exist in most cases. (Though a usable, FOSS alternative to the
> GIMP (GUI, of course, but *highly* idiosyncratic to anyone used to
> Photoshop) still seems strangely lacking ...)
>
> Mind you, it still can impinge on others from time to time. For
> example, by causing a not-insignificant fraction of mailing list
> traffic on some lists to consist of questions like "how do I make
> ancient ASCII-terminal-oriented piece of software Foo play nice with
> Unicode characters transmitted over the network?" and answers to same.
> :)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to c

Re: Setting up Emacs to edit Clojure for Windows folks

2012-01-25 Thread Sean Corfield
On Wed, Jan 25, 2012 at 10:21 PM, Cedric Greevey  wrote:
> I guess you're talking about a different kind of usability than I am.

Like I said:

"I'm sure we'll just agree to disagree on this one..."

> On the other hand, there's "setup for the typical configuration is
> point, click, reboot, done

And that indicates the fundamental difference of opinion: point,
click, reboot. To me, that simply is not usable. I want to edit text
and not have to reboot. YMMV.

[huge amount of words snipped]

I'll repeat:

"I'm sure we'll just agree to disagree on this one..."
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
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: Setting up Emacs to edit Clojure for Windows folks

2012-01-25 Thread Cedric Greevey
On Thu, Jan 26, 2012 at 12:25 AM, Sean Corfield  wrote:
> On Wed, Jan 25, 2012 at 9:18 PM, Cedric Greevey  wrote:
>> In other words, "ported software setup sucks!"? :)
>
> That's not the conclusion I would have drawn... ;)
>
>> Rather ironic, when the tendency, at least historically, has been for
>> Windows (and Mac) to have superior usability when it comes to native
>
> That depends on your point of view. I don't consider Windows
> particularly usable - and I've used every version of it from 3.1 to
> date... I'm sure we'll just agree to disagree on this one...

I guess you're talking about a different kind of usability than I am.

On the one hand, there's "it works properly and doesn't constantly
crash". That's where Windows software has tended to be deficient (and,
until recently, security).

On the other hand, there's "setup for the typical configuration is
point, click, reboot, done, and then you can sit down at it and use it
with domain knowledge, general computer skills, and little else, and
generally only need to consult some thick manual, or a cheat-sheet, or
forums, or Wikipedia, or something when you're doing something unusual
or advanced rather than common tasks such as cut, copy, and paste".
That's where Unix software has tended to be deficient, often requiring
complicated setup (though sometimes not) and almost always requiring a
cheat-sheet, at least, to use it if you aren't a very regular,
experienced user of the software. Frequently solution-space knowledge
is even needed -- knowledge of compilers, terminology like "buffer",
and so forth. Non-industry-standard bindings, mouse input semantics,
selection and menu behavior (if there even are menus), and terminology
abound in the typical case, up to and including various idiosyncratic
neologisms specific to a single piece of software and not used by
unrelated software with the same function (e.g. only emacs calls the
clipboard or clipboards a "kill ring"; not only doesn't Notepad, nor
does Editpad, Notepad++, vi, nano ...).

Newer stuff, particularly designed for use with a package manager at
install time and either Gnome or KDE, has tended to avoid these
problems, though. Hence the "at least historically" above.

Of course, this isn't limited purely to Unix. Before widespread
networking and large market penetration of Windows PCs, idiosyncratic
software and multiple attempts at standards proliferated on most
platforms, excluding the Mac which came OOTB with a standard GUI
toolkit. Old MS-DOS software is as guilty as vintage Unix software,
with Wordstar and ancient versions of Lotus Notes (even for a while
after it got a GUI!) being particularly infamous for requiring of
users enormous feats of application-specific memorization and/or
cheat-sheets.

On the other hand, nobody uses those old pieces of MS-DOS software
anymore. For some reason correspondingly old Unix software has a
to-some-dismaying tendency to stay in use year after year. :)

Actually, this may be a downside of open source. The likely reason is
that the old MS-DOS software is proprietary, no longer maintained by
the original developers, and in all likelihood no longer even exists
as source, whereas the old Unix software is open source and people
that got used to it stuck with it and even kept developing it
themselves, so the software outlives generation after generation of
hardware and is functionally immortal, but inertia keeps it full of
legacy idiosyncrasies from before common idioms of computer
interaction became standardized as a consequence of the computer
becoming a common household tool rather than something only used at
work, at school, and by geeks. So, open source seems to result in
keeping old, pre-standardization things in use until the *users* die
off rather than the hardware generation that begat it.

On the positive side, nobody is forced at gunpoint to use any of it
and standard-compliant alternatives that you can just sit at and use
tend to exist in most cases. (Though a usable, FOSS alternative to the
GIMP (GUI, of course, but *highly* idiosyncratic to anyone used to
Photoshop) still seems strangely lacking ...)

Mind you, it still can impinge on others from time to time. For
example, by causing a not-insignificant fraction of mailing list
traffic on some lists to consist of questions like "how do I make
ancient ASCII-terminal-oriented piece of software Foo play nice with
Unicode characters transmitted over the network?" and answers to same.
:)

-- 
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: Setting up Emacs to edit Clojure for Windows folks

2012-01-25 Thread Sean Corfield
On Wed, Jan 25, 2012 at 9:18 PM, Cedric Greevey  wrote:
> In other words, "ported software setup sucks!"? :)

That's not the conclusion I would have drawn... ;)

> Rather ironic, when the tendency, at least historically, has been for
> Windows (and Mac) to have superior usability when it comes to native

That depends on your point of view. I don't consider Windows
particularly usable - and I've used every version of it from 3.1 to
date... I'm sure we'll just agree to disagree on this one...
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
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: Setting up Emacs to edit Clojure for Windows folks

2012-01-25 Thread Cedric Greevey
On Wed, Jan 25, 2012 at 10:51 PM, Sean Corfield  wrote:
> On Wed, Jan 25, 2012 at 4:55 PM, Cedric Greevey  wrote:
>> This isn't, by the way, to say that "emacs sucks!". It's more "emacs
>> setup sucks!" with perhaps a dash of "ported software sucks!"
>
> Well, it's certainly a truism that *nix-based software is harder to
> setup on Windows than on Mac/Linux.

In other words, "ported software setup sucks!"? :)

> I think that's because most folks who develop open source software
> systems tend to use *nix-based machines (Mac/Linux) so it ends up
> being the job of Windows users to help test, debug, document and
> provide patches for the software so that the Windows experience
> becomes more bearable...

Rather ironic, when the tendency, at least historically, has been for
Windows (and Mac) to have superior usability when it comes to native
(rather than ported) software. Of course, Unix suffers somewhat from
competing standards (try finding any two Unix text editors first
written before 1995 or so that have the same keybindings!) and being
more variable than either Windows or Mac (XP vs. Vista vs. Windows 7
is nothing compared to Debian Linux vs. Ubuntu Linux vs. Slackware,
Knoppix, etc., etc., etc., vs. OpenBSD, vs. AT&T Unix, vs. ...

-- 
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: Setting up Emacs to edit Clojure for Windows folks

2012-01-25 Thread Sean Corfield
On Wed, Jan 25, 2012 at 4:55 PM, Cedric Greevey  wrote:
> This isn't, by the way, to say that "emacs sucks!". It's more "emacs
> setup sucks!" with perhaps a dash of "ported software sucks!"

Well, it's certainly a truism that *nix-based software is harder to
setup on Windows than on Mac/Linux.

I think that's because most folks who develop open source software
systems tend to use *nix-based machines (Mac/Linux) so it ends up
being the job of Windows users to help test, debug, document and
provide patches for the software so that the Windows experience
becomes more bearable...
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
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: Setting up Emacs to edit Clojure for Windows folks

2012-01-25 Thread Lars Nilsson
Assuming people attempting to use Emacs for Clojure are not adverse to
mucking around with Emacs init files... Also given are clojure-mode.el
in the .emacs.d directory, lein in PATH.

(add-to-list 'load-path (expand-file-name ".emacs.d" "~"))

(autoload 'clojure-mode "clojure-mode" "A major mode for Clojure" t)
(add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode))

(setq inferior-lisp-program "lein repl")

(add-hook 'clojure-mode-hook
  '(lambda ()
 (setq indent-tabs-mode nil)
 (define-key clojure-mode-map "\C-c\C-e" 'lisp-eval-last-sexp)
 (define-key clojure-mode-map "\C-x\C-e" 'lisp-eval-last-sexp)))

I use this just fine for my purposes on Linux, Windows XP and Windows
7. I invoke M-x run-lisp from within a lein project 99% of the time
and send expressions over from my editing frame using the above
keybindings, and test functions, etc, in the repl frame.

Maybe one day I'll look at slime/swank stuff, but I haven't found
myself needing much more than this so far.

Lars Nilsson

-- 
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: ClojureScript One - Getting Started with ClojureScript

2012-01-25 Thread Phil Hagelberg
Raju Bitter  writes:

> Thanks for your help. Should have looked into the Leiningen issues myself.

Just a heads-up; this is fixed in the 1.x branch of Leiningen.

I hope to have a stable release in a couple weeks.

-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: ClojureScript One - Getting Started with ClojureScript

2012-01-25 Thread Raju Bitter
Thanks for your help. Should have looked into the Leiningen issues myself.

- Raju

-- 
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: Setting up Emacs to edit Clojure for Windows folks

2012-01-25 Thread Roberto Mannai
My notes about installing Emacs 24 on Windows 7, with clojure support:
http://sourceforge.net/apps/wordpress/codesounding/2011/09/29/installing-emacs-24-and-clojure-mode-on-windows-7-step-by-step/

On Wed, Jan 25, 2012 at 11:40 PM, Sean Corfield wrote:

>
> http://corfield.org/articles/emacs_win.html
>
> But whilst it worked on XP, various folks could not get it to work on
> Win7 so I never turned it into a formal blog post...
> --
> Sean A Corfield -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
> World Singles, LLC. -- http://worldsingles.com/
>
> "Perfection is the enemy of the good."
> -- Gustave Flaubert, French realist novelist (1821-1880)
>
> --
> 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: ClojureScript One - Getting Started with ClojureScript

2012-01-25 Thread Brenton
This is not an issue with One but with Leiningen. Others have run into
the same problem:

https://github.com/technomancy/leiningen/issues/375

https://github.com/dakrone/clojuredocs-client/issues/6

Another work-around is to make sure you have clojure-1.2.1 in your
local maven repository.

On Jan 25, 7:23 pm, Raju Bitter  wrote:
> I don't have a $CLASSPATH set, and no ~/.clojure folder, so there
> shouldn't be any conflicting Clojure JAR file on the classpath.
>
> - Raju

-- 
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: Setting up Emacs to edit Clojure for Windows folks

2012-01-25 Thread Cedric Greevey
I think it may be worth noting the size and complexity of that blog
post in contrast to these:

Netbeans setup on Windows:

1. Download Netbeans+JDK from the options at the Netbeans site.
2. Run installer.
3. Run Netbeans.
4. Browse in its built-in plugin-browser for Enclojure and install that.
5. Create a project and launch a REPL.

Now you have a working Clojure code editor and Clojure REPL and can
evaluate expressions from the one in the other.

Eclipse setup on Windows:

1. Download Eclipse+JDK from the options at the Eclipse site.
2. Run installer.
3. Run Eclipse.
4. Browse in its built-in plugin-browser for CCW and install that.
5. Tools/Refresh Perspective or something similar.
6. Create a project and launch a REPL.

Now you have a working Clojure code editor and Clojure REPL and can
evaluate expressions from the one in the other.

Clooj setup on Windows:

1. Download a JDK (or maybe even a JRE?).
2. Install it.
3. Download clooj.
4. Double-click jar file for clooj.
5. Create a project and launch a REPL.

Now you have a working Clojure code editor and Clojure REPL and can
evaluate expressions from the one in the other.

I think all three of these *combined* are probably simpler than that
blog post. There's also only one arguably
tricky/nonobvious/RTFM-requiring step, and that's step 5 in the
Eclipse setup. From the original post's description, the whole
motivation of the blog post is to document the tricky steps for the
emacs setup, of which there are apparently a great many.

This isn't, by the way, to say that "emacs sucks!". It's more "emacs
setup sucks!" with perhaps a dash of "ported software sucks!"; the
other three options above may also not be native Windows software, per
se, but they are a) explicitly OS-neutral rather than designed
originally for a specific OS that isn't Windows and b) obedient
towards what have become, for better or for worse, the world's defacto
standard editor-keybinding and GUI conventions.

-- 
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: ClojureScript One - Getting Started with ClojureScript

2012-01-25 Thread Raju Bitter
I don't have a $CLASSPATH set, and no ~/.clojure folder, so there
shouldn't be any conflicting Clojure JAR file on the classpath.

- Raju

-- 
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: ClojureScript One - Getting Started with ClojureScript

2012-01-25 Thread Raju Bitter
> 3) Try to launch the repl, but that fails. Seems to be a classpath
> issue, looks like Leiningen is not finding the Clojure JAR file. Any
> idea what this might be?
> raju@titan:~/test/one$ lein repl
> Exception in thread "main" java.lang.RuntimeException:
> java.lang.NoSuchMethodError:
> clojure.lang.KeywordLookupSite.(ILclojure/lang/Keyword;)V
That's strange, when I delete clojure-1.3.0.jar in one/lib/dev, I can
launch the repl and (go):

raju@titan:~/test/one$ rm lib/dev/clojure-1.3.0.jar
raju@titan:~/test/one$ lein repl
REPL started; server listening on localhost port 38304

Type (go) to launch the development server and setup a browser-connected REPL.
Type (dev-server) to launch only the development server.

one.sample.repl=> (go)
2012-01-26 01:20:39.364:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
"Type: " :cljs/quit " to quit"
2012-01-26 01:20:39.365:INFO::jetty-6.1.25
2012-01-26 01:20:39.374:INFO::Started SocketConnector@0.0.0.0:8080
ClojureScript:cljs.user>

-- 
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: ClojureScript One - Getting Started with ClojureScript

2012-01-25 Thread Raju Bitter
Thanks for your response, Brenton.

2012/1/25 Brenton :
> With the recent update, we no longer have a script/cljs-repl.
>
> You would now use:
>
> lein repl
> (go)
That works on OS X.

On Ubuntu 11.04 - with a clean system (no Leiningen / Clojure installed), I do
1) Install Leiningen, lein works
lein -v
raju@titan:~/test$ lein -v
Leiningen 1.6.2 on Java 1.6.0_30 Java HotSpot(TM) 64-Bit Server VM

2) Checkout ClojureScript One
raju@titan:~/test$ git clone https://github.com/brentonashworth/one.git
Cloning into one...
remote: Counting objects: 1574, done.
remote: Compressing objects: 100% (658/658), done.
remote: Total 1574 (delta 738), reused 1532 (delta 696)
Receiving objects: 100% (1574/1574), 940.66 KiB | 224 KiB/s, done.
Resolving deltas: 100% (738/738), done.
raju@titan:~/test$ cd one
raju@titan:~/test/one$ lein bootstrap
Copying 36 files to /home/raju/test/one/lib
Copying 10 files to /home/raju/test/one/lib/dev
Setting up dependency for
[https://github.com/clojure/clojurescript.git
886d8dc81812962d30a741d6d05ce9d90975160f]
Running git checkout  886d8dc81812962d30a741d6d05ce9d90975160f  in
.lein-git-deps/clojurescript
Setting up dependency for  [https://github.com/levand/domina.git
8933b2d12c44832c9bfaecf457a1bc5db251a774]
Running git checkout  8933b2d12c44832c9bfaecf457a1bc5db251a774  in
.lein-git-deps/domina

3) Try to launch the repl, but that fails. Seems to be a classpath
issue, looks like Leiningen is not finding the Clojure JAR file. Any
idea what this might be?
raju@titan:~/test/one$ lein repl
Exception in thread "main" java.lang.RuntimeException:
java.lang.NoSuchMethodError:
clojure.lang.KeywordLookupSite.(ILclojure/lang/Keyword;)V
at clojure.lang.Util.runtimeException(Util.java:165)
at clojure.lang.Compiler.eval(Compiler.java:6476)
at clojure.lang.Compiler.eval(Compiler.java:6431)
at clojure.core$eval.invoke(core.clj:2795)
at clojure.main$eval_opt.invoke(main.clj:296)
at clojure.main$initialize.invoke(main.clj:315)
at clojure.main$script_opt.invoke(main.clj:339)
at clojure.main$main.doInvoke(main.clj:426)
at clojure.lang.RestFn.invoke(RestFn.java:457)
at clojure.lang.Var.invoke(Var.java:413)
at clojure.lang.AFn.applyToHelper(AFn.java:172)
at clojure.lang.Var.applyTo(Var.java:518)
at clojure.main.main(main.java:37)
Caused by: java.lang.NoSuchMethodError:
clojure.lang.KeywordLookupSite.(ILclojure/lang/Keyword;)V

4) Confirm that lein works correctly
raju@titan:~/test$ lein new hello-world
Created new project in: /home/raju/test/hello-world
Look over project.clj and start coding in hello_world/core.clj
raju@titan:~/test$ cd hello-world/
raju@titan:~/test/hello-world$ lein deps
Copying 1 file to /home/raju/test/hello-world/lib
raju@titan:~/test/hello-world$ lein repl
REPL started; server listening on localhost port 53851
user=>

Has anyone else experienced similar problems on Ubuntu with ClojureScript One?

- Raju

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


ClojureScript One bootstrap problem on Windows?

2012-01-25 Thread David Powell
Hmm, I seem to be having a problem with the new bootstrap script.

On Windows, I'm running:
git version 1.7.7.msysgit.1

This release puts: "c:\Program Files (x86)\Git\cmd\" on the PATH,
which contains a git.cmd (batch file) which runs the .exe.

Unfortunately, Runtime.exec won't run batch files unless you
explicitly run them via the shell, eg:

(sh "cmd" "/c" "git" "clone" ...)

rather than:

(sh "git" "clone" ...)

-- 
Dave

-- 
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: Setting up Emacs to edit Clojure for Windows folks

2012-01-25 Thread Sean Corfield
On Wed, Jan 25, 2012 at 11:59 AM, Rick Hall  wrote:
> For anyone who needs the help, the post is here:
> http://onbeyondlambda.blogspot.com/2012/01/setting-up-clojure-emacs-on-windows.html

Thanx Rick. I started down a similar path and got these instruction
pulled together:

http://corfield.org/articles/emacs_win.html

But whilst it worked on XP, various folks could not get it to work on
Win7 so I never turned it into a formal blog post...
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
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: Setting up Emacs to edit Clojure for Windows folks

2012-01-25 Thread daly
On Wed, 2012-01-25 at 11:59 -0800, Rick Hall wrote:
> I tried to set up a development environment for Clojure on a Windows
> box.  As you all know there are lots of editors available and multiple
> ways of setting up each editor.  There are also several versions of
> instructions as the process has changed over time.
> 
> I have virtually never ventured out of Visual Studio for the past 8
> years.  I found the range of options overwhelming, and while I
> understand the instructions more clear in retrospect I thought it
> might be nice to leave a trail for those who follow behind me.
> 
> I have written a blog post that shows how to install the jdk,
> leigingen, emacs, clojure-mode and slime.  The level of detail in some
> places may seem excessive, but given the amount of time it took me to
> comprehend instructions like: from within a project insert M-x clojure-
> jack-in, I figured it was better to err on the side of detail.
> 
> For anyone who needs the help, the post is here:
> http://onbeyondlambda.blogspot.com/2012/01/setting-up-clojure-emacs-on-windows.html
> 

I had some trouble getting slime to work on windows.

If you are running emacs you can get a lot of functionality
with simple keyboard macros. If you split the screen
'Ctrl-x 2'
and start a shell buffer 
'Meta-x shell'
you can run clojure in the shell. You can edit lisp in the
other buffer and use
'Ctrl-x o'
to switch between the buffers.

A simple keyboard macro can be set on a key (e.g. f1) with

'Meta-:'
(global-set-key [f1] 
  "\C-x/1\C-[\C-a\C-@\C-[\C-f\C-[w\C-xo\C-y\C-m\C-xo\C-xj1")

Pressing the F1 key now will evaluate the s-expression that
contains the point. This works by:
(remember the position)   "\C-x/1"
(go to the beginning) "\C-[\C-a"
(remember the point)  "\C-@"
(mark the s-expression)   "\C-[\C-f"
(push it to the killring) "\C-[w"
(switch to other buffer)  "\C-xo"
(yank the s-expression)   "\C-y"
(hit enter to eval it)"\C-m"
(switch to other buffer)  "\C-xo"
(go back to position) "\C-xj1"

Tim Daly


-- 
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: New Version of ClojureScript One

2012-01-25 Thread Brenton
> One quick question - why do you still rely on git checkouts of ClojureScript 
> and Domina - especially now ClojureScript is available on maven?

ClojureScript will continue to change rapidly. We are already
depending on a newer version than the one in Maven. Also, I don't
think that Domina has a release yet.

For times when we only need a source dependency and only at
development time, I like this approach to dependencies. I plan to
continue improving support for this in Leiningen and using it as much
as i can.

For more of the rationale, see 
https://github.com/brentonashworth/one/wiki/Dependencies.

You rock!

Brenton

On Jan 25, 4:15 pm, Sam Aaron  wrote:
> Very nice :-) I've got some quality code reading ahead of me...
>
> One quick question - why do you still rely on git checkouts of ClojureScript 
> and Domina - especially now ClojureScript is available on maven?
>
> Sam
>
> ---http://sam.aaron.name
>
> On 25 Jan 2012, at 20:40, Brenton wrote:
>
>
>
>
>
>
>
> > We have released a new version of ClojureScript One.
>
> > The most significant changes are:
>
> > No more scripts! Everything now works through Leiningen. We have added
> > support for retrieveing git dependencies via Leiningen.
>
> > Allow connections to the REPL form remote machines.
>
> > See the change log:
>
> >https://github.com/brentonashworth/one/wiki/Change-Log
>
> > --
> > 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: Setting up Emacs to edit Clojure for Windows folks

2012-01-25 Thread Phil Hagelberg
Rick Hall  writes:

> I have written a blog post that shows how to install the jdk,
> leigingen, emacs, clojure-mode and slime.  The level of detail in some
> places may seem excessive, but given the amount of time it took me to
> comprehend instructions like: from within a project insert M-x clojure-
> jack-in, I figured it was better to err on the side of detail.

Have you considered contributing to the existing documentation where you
found it lacking? That way it can be amended in the future when things
change, as they are bound to do.

-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


One-day conference: Functional Programming eXchange, March 16th, London

2012-01-25 Thread Anaïs
You're invited to our 1-day conference on Functional Programming at
the Skills Matter eXchange, London's meetup space for the developer
community. Join leading experts in the field to learn and share the
latest innovative ideas, best tools and practices in the different
programming languages (scala, clojure, haskell, F#) and environments.
Programme and booking details at the link:

http://skillsmatter.com/event/scala/functional-programming-exchange-2012/ac-3451

What: Functional Programming eXchange 2012
When: March 16th 2012, Breakfast and registration at 8.30
Where: Skills Matter, 116-120 Goswell Road, London, EC1V 7DP
Twitter: #functionalpx @AnaisatSM @skillsmatter
Experts:
Robert Pickering
David Pollak
Erik Hesselink
Loic Denuziere
Kevin Wright
Andres Löh
Thomas Petricek
Miles Sabin
Bruce Durling

-- 
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: Concurrency Talk materials

2012-01-25 Thread Sergey Stupin
Thank you sooo much. Its exactly that i was searching for. I have not 
thought of googling "ClojureConcurrencyTalk.pdf". My queries were just like 
"clojure concurrency talk slides". Thank you!

-- 
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: How to add a new type of collection?

2012-01-25 Thread joachim
Great, thanks people.

So to be surfe I understand, let me summarize as follows: There are
two ways to go:

(1) import the existing sparse matrix class in my clojure project and
wrap a new type around it that implements all required java interfaces
(using them as protocols)
(2) code a new java class that implements the java interfaces directly
and import it in clojure

Correct?

Then I think I would go for option (1), since I am not sure what the
added value is of doing (2). I'm not also sure how to deal with
persitency/thread safety. So far I came up with this:

(ns utils.sparse
  (:import (org.apache.mahout.math RandomAccessSparseVector)))

(deftype SparseVector [v]
clojure.lang.Counted
(count [this] (.size v))
   clojure.lang.Indexed
   (nth [this index] (if (< index (.size v))
 (.getQuick v index)
...
   clojure.lang.IPersistentMap
   (assoc [this idx val]
 (SparseVector. (RandomAccessSparseVector. ... ;;; use a fresh
RASP (further initialization code not shown)

(defn sparse-vector
  ([size]
 (sparse-vector size {}))
  ([size & idxvals]
 (SparseVector. (doto (RandomAccessSparseVector. size)
((fn [vec] (doseq [[idx val] idxvals]
(.setQuick vec idx
val

Is this the best way to go? Another possibility is to wrap the RASP in
an atom:

(ns utils.sparse
  (:import (org.apache.mahout.math RandomAccessSparseVector)))

(deftype SparseVector [v]
  ...
  clojure.lang.IPersistentMap
  (assoc [this idx val]
(swap! v (fn [rasv] (.setQuick rasv idx val))) ;;; side effects
this))

(defn sparse-vector
  ([size]
 (sparse-vector size {}))
  ([size & idxvals]
 (SparseVector. (atom (doto (RandomAccessSparseVector. size) ;;;
make atomic to cope with side effects
 ((fn [vec] (doseq [[idx val]
idxvals]
  (.setQuick
vec idx val)

I have a feeling that the first approach is preferred, but I'm not
sure why, and also not when to use atoms in general?

Anyway, thanks again, and I would be happy to hear any further
comments and suggestions!

Joachim.

-- 
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: Clojure for Cocoa

2012-01-25 Thread D.Theisen
Hello, Matthias!

On Jan 24, 6:53 am, Matthias Benkard  wrote:
> Toilet Lisp is an incomplete implementation of Common Lisp hosted on
> the Objective-C runtime.  It includes both an interpreter and an LLVM-
> based compiler, which, IIRC, are actually complete.  (It's the
> standard library that's missing.)
>
> You might be able to leverage some of it.

Interesting!

How did you handle the reference counting vs. Garbage Collection
chasm?

Dirk

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


Setting up Emacs to edit Clojure for Windows folks

2012-01-25 Thread Rick Hall
I tried to set up a development environment for Clojure on a Windows
box.  As you all know there are lots of editors available and multiple
ways of setting up each editor.  There are also several versions of
instructions as the process has changed over time.

I have virtually never ventured out of Visual Studio for the past 8
years.  I found the range of options overwhelming, and while I
understand the instructions more clear in retrospect I thought it
might be nice to leave a trail for those who follow behind me.

I have written a blog post that shows how to install the jdk,
leigingen, emacs, clojure-mode and slime.  The level of detail in some
places may seem excessive, but given the amount of time it took me to
comprehend instructions like: from within a project insert M-x clojure-
jack-in, I figured it was better to err on the side of detail.

For anyone who needs the help, the post is here:
http://onbeyondlambda.blogspot.com/2012/01/setting-up-clojure-emacs-on-windows.html

-- 
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: New Version of ClojureScript One

2012-01-25 Thread Rafał Babinicz
Thanks for great work, Brenton. Keep it coming!

PS
I stubbed sever side of 'CS One's example, but still have some
troubles with making it work on mobile browsers.
Anybody try this with success?

-- 
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: [ANN] New Version of ClojureScript One

2012-01-25 Thread Stuart Sierra
"Why git checkouts?"

We don't have automated Maven releases of ClojureScript yet, so to pull the 
latest code it needs to get it from git.

Maybe this Friday I'll be able to get automated releases up on Hudson.
-S

-- 
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: Adding primitive type hints to anonymous functions

2012-01-25 Thread Cedric Greevey
On Wed, Jan 25, 2012 at 11:58 AM, Ben Mabey  wrote:
> On 1/25/12 2:25 AM, Tassilo Horn wrote:
>>
>> Hi again,
>>
>> I think, I got it.  I wrote a little helper function to print the
>> metadata of a form:
>>
>> --8<---cut here---start->8---
>> (use 'clojure.walk)
>> (defn print-meta
>>   ([form level]
>>      (prewalk
>>       (fn [x]
>>         (when-let [m (meta x)]
>>           (println "Level" level ":" x "=>" m)
>>           (print-meta m (inc level)))
>>         x)
>>       form))
>>   ([form]
>>      (print-meta form 0)))
>> --8<---cut here---end--->8---
>>
>> Now see what happens:
>>
>> --8<---cut here---start->8---
>> user>  (print-meta (macroexpand-all '(def b (fn ^foo [^bar x] ^baz x
>> Level 0 : x =>  {:tag bar}
>> Level 0 : x =>  {:tag baz}
>> (def b (fn* ([x] x)))
>> user>  (print-meta (macroexpand-all '(defn b ^foo [^bar x] ^baz x)))
>> Level 0 : b =>  {:arglists (quote ([x]))}
>> Level 1 : [x] =>  {:tag foo}
>> Level 1 : x =>  {:tag bar}
>> Level 0 : x =>  {:tag bar}
>> Level 0 : x =>  {:tag baz}
>> (def b (fn* ([x] x)))
>> --8<---cut here---end--->8---
>>
>> So the return type metadata is actually added to the :arglist metadata
>> contents, so it's actually meta-metadata.  What you seem to have to do
>> is to make sure the :arglists metadata is there and reflects the type
>> hints on the actual function:
>>
>> --8<---cut here---start->8---
>> user>  (def ^{:arglists '(^double [^double x])}
>>           with-def  (fn ^double [^double x] (+ x  0.5)))
>> #'user/with-def
>> user>  (pt (with-def 1))
>> :double
>> --8<---cut here---end--->8---
>>
>> Well, that's not really obvious.  Maybe `def' could do a better job here
>> and build up a correct :arglists metadata value somehow...
>>
>> Bye,
>> Tassilo
>>
> Hi Tassilo,
> Thanks for doing the detective work!  I still have some questions though...
>  In my example I used def because I was able to reproduce the bug with def
> and it was the easiest way to show it. However, in practice these anonymous
> functions won't be bound to a root var (hence the anonymous part :) ). I
> would like to be able to write code like this:
>
> (map-doubles (fn ^double [^double x] (+ x 0.5)) array)
>
> I don't seem to be able to do that since the type hints are not put into
> effect without a var (it would seem):
>
> (pt ((fn ^double [^double x] (+ x 0.5)) 1.0)) ; => :object
>
> Not just put into effect, but not even stored on the function (as far as I
> can tell):
>
> (meta  (fn ^double [^double x] (+ x 0.5))) ; => nil
>
> I've tried adding the appropriate metadata onto the function (I'm stealing
> the metadata from our earlier with-defn):
>
> (meta (with-meta (fn ^double [^double x] (+ x 0.5)) (select-keys (meta
> #'with-defn) [:arglists]))) ; => {:arglists ([x])}
>
> I can verify that the arglist is tagged with the primitive just like it is
> with the var #'with-defn:
>
> (defn arglist-tag [var]
>  (-> var meta :arglists first meta :tag))
>
> (arglist-tag #'with-defn) ; => double
> (arglist-tag (with-meta (fn ^double [^double x] (+ x 0.5)) (select-keys
> (meta #'with-defn) [:arglists])))A ; => double
>
> Sadly, even with the arglist meta-metadata boxing is still occurring:
>
> (pt ((with-meta (fn ^double [^double x] (+ x 0.5)) (select-keys (meta
> #'with-defn) [:arglists])) 1.0)) ; => object
>
> It is probably obvious that this would not work to someone who understands
> clojure's implementation, but to me this was a surprise.  From this I gather
> that type hints on vars are what clojure uses and type hints on the actual
> functions are ignored.
>
> Am I missing something, or does the new primitive support only apply to
> bound functions?

It's even stranger than that. It won't work with local Vars:

user=> (with-local-vars [a (fn [^double x] (+ x 0.5))] (.setMeta a
{:tag Double/TYPE}) (pt (a 0.1)))
:object

And yes, there's a {:tag double} on a after the .setMeta call. In
fact, that degree of hackery is needed. Neither ^double nor ^{:tag
Double/TYPE} on the a in the binding form will attach the metadata to
the Var, unlike with def, where the latter works (and the former seems
to, at first, but fails when the fn is called with a *very strange*
error message about a class named clojure.core$double@1eb1db2 not
being resolved).

Attaching ^double or ^{:tag Double/TYPE} to the (fn ...) form itself
also does not work, there or with a normal let-bound local.

Either PrimitiveTester doesn't work the way it seems like it should,
or else something's strange/wonky with how Clojure compiles function
calls that don't use a namespaced global Var.

Actually, on further testing, I'm not sure that (def ^{Double/TYPE}
...) is really working either, rather than boxing and then unboxing on
each call:

user=> (def ^{:tag Double/TYPE} b (fn [^double x] (+ x 0.5)))
#'

Re: No support for primitive type returns within protocols (1.3)?

2012-01-25 Thread David Nolen
On Wed, Jan 25, 2012 at 3:51 PM, Ben Mabey  wrote:

>  On 1/25/12 1:41 PM, David Nolen wrote:
>
> On Wed, Jan 25, 2012 at 3:34 PM, Ben Mabey  wrote:
>
>> Hi again,
>>
>> Is it possible to add primitive type hints to protocols (as the return
>> type)?  My attempt below failed:
>>
>> (definterface IPrimitiveTester
>>  (getType [^int x])
>>  (getType [^long x])
>>  (getType [^float x])
>>  (getType [^double x])
>>  (getType [^Object x]))
>>
>> (deftype PrimitiveTester []
>>  IPrimitiveTester
>>  (getType [this ^int x] :int)
>>  (getType [this ^long x] :long)
>>  (getType [this ^float x] :float)
>>  (getType [this ^double x] :double)
>>  (getType [this ^Object x] :object))
>>
>>
>> (defmacro primitive-type [x]
>>  `(.getType (PrimitiveTester.) ~x))
>>
>> (defmacro pt [x]
>>  `(.getType (PrimitiveTester.) ~x))
>>
>> (defprotocol Foo
>>  (bar [foo]))
>>
>> (deftype Dog []
>>  Foo
>>  (bar ^double [_] 42.0))
>>
>> (pt (bar (Dog.))) ; => :object
>>
>> (I also tried adding the hint to the protocol definition but that
>> resulted in a compiler error.)
>>
>> In my googling the only other reference to protocols with primitive
>> support was an unanswered question on this mailing list last November[1].
>>  Hopefully my question gets a little more attention...
>>
>> (Pardon all these primitive type questions but I'm in the process of
>> upgrading a 1.2 app to 1.3 and trying to convert some of our numeric heavy
>> java code into clojure in the process.)
>>
>> Thanks,
>> Ben
>>
>> 1.
>> http://groups.google.com/group/clojure/browse_thread/thread/6015aacd6e8d0d20/ccca98bea3970240
>>
>
>  It's not currently supported.
>
>  Do you know if support is planned (i.e. a ticket exists)?
>

I don't think support is planned and given that it hasn't been done yet I
imagine that it's challenging / impossible. You have definterface and prim
fns in the mean time.

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: ClojureScript One - Getting Started with ClojureScript

2012-01-25 Thread Brenton
With the recent update, we no longer have a script/cljs-repl.

You would now use:

lein repl
(go)

to accomplish the same thing.

In your case, you can use:

lein repl
(binding [*open-url-script* x]
  (go))

Brenton

On Jan 25, 3:19 pm, Raju Bitter  wrote:
> clojure.java.browse/open-url-in-swing is called a fallback method, and
> then the ClojureScript app is not rendered correctly.
>
> http://bit.ly/yPagHl
>
> I'll see if I can create a workaround for that.
>
> - Raju

-- 
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: [ANN] New Version of ClojureScript One

2012-01-25 Thread Sam Aaron
Very nice :-) I've got some quality code reading ahead of me...

One quick question - why do you still rely on git checkouts of ClojureScript 
and Domina - especially now ClojureScript is available on maven?

Sam

---
http://sam.aaron.name

On 25 Jan 2012, at 20:40, Brenton wrote:

> We have released a new version of ClojureScript One.
> 
> The most significant changes are:
> 
> No more scripts! Everything now works through Leiningen. We have added
> support for retrieveing git dependencies via Leiningen.
> 
> Allow connections to the REPL form remote machines.
> 
> See the change log:
> 
> https://github.com/brentonashworth/one/wiki/Change-Log
> 
> -- 
> 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: [ANN] New Version of ClojureScript One

2012-01-25 Thread Ryan Waters
On Wed, Jan 25, 2012 at 2:40 PM, Brenton  wrote:
> We have released a new version of ClojureScript One.
>
> ...
>
> No more scripts! Everything now works through Leiningen. We have added
> support for retrieveing git dependencies via Leiningen.
>

It's nice that leiningen can handle the classpath issues and repl now.
 I bet clojure-jack-in works too.  Thank you!

- Ryan

-- 
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: No support for primitive type returns within protocols (1.3)?

2012-01-25 Thread Ben Mabey

On 1/25/12 1:41 PM, David Nolen wrote:
On Wed, Jan 25, 2012 at 3:34 PM, Ben Mabey > wrote:


Hi again,

Is it possible to add primitive type hints to protocols (as the
return type)?  My attempt below failed:

(definterface IPrimitiveTester
 (getType [^int x])
 (getType [^long x])
 (getType [^float x])
 (getType [^double x])
 (getType [^Object x]))

(deftype PrimitiveTester []
 IPrimitiveTester
 (getType [this ^int x] :int)
 (getType [this ^long x] :long)
 (getType [this ^float x] :float)
 (getType [this ^double x] :double)
 (getType [this ^Object x] :object))


(defmacro primitive-type [x]
 `(.getType (PrimitiveTester.) ~x))

(defmacro pt [x]
 `(.getType (PrimitiveTester.) ~x))

(defprotocol Foo
 (bar [foo]))

(deftype Dog []
 Foo
 (bar ^double [_] 42.0))

(pt (bar (Dog.))) ; => :object

(I also tried adding the hint to the protocol definition but that
resulted in a compiler error.)

In my googling the only other reference to protocols with
primitive support was an unanswered question on this mailing list
last November[1].  Hopefully my question gets a little more
attention...

(Pardon all these primitive type questions but I'm in the process
of upgrading a 1.2 app to 1.3 and trying to convert some of our
numeric heavy java code into clojure in the process.)

Thanks,
Ben

1.

http://groups.google.com/group/clojure/browse_thread/thread/6015aacd6e8d0d20/ccca98bea3970240


It's not currently supported.


Do you know if support is planned (i.e. a ticket exists)?

--
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: No support for primitive type returns within protocols (1.3)?

2012-01-25 Thread David Nolen
On Wed, Jan 25, 2012 at 3:34 PM, Ben Mabey  wrote:

> Hi again,
>
> Is it possible to add primitive type hints to protocols (as the return
> type)?  My attempt below failed:
>
> (definterface IPrimitiveTester
>  (getType [^int x])
>  (getType [^long x])
>  (getType [^float x])
>  (getType [^double x])
>  (getType [^Object x]))
>
> (deftype PrimitiveTester []
>  IPrimitiveTester
>  (getType [this ^int x] :int)
>  (getType [this ^long x] :long)
>  (getType [this ^float x] :float)
>  (getType [this ^double x] :double)
>  (getType [this ^Object x] :object))
>
>
> (defmacro primitive-type [x]
>  `(.getType (PrimitiveTester.) ~x))
>
> (defmacro pt [x]
>  `(.getType (PrimitiveTester.) ~x))
>
> (defprotocol Foo
>  (bar [foo]))
>
> (deftype Dog []
>  Foo
>  (bar ^double [_] 42.0))
>
> (pt (bar (Dog.))) ; => :object
>
> (I also tried adding the hint to the protocol definition but that resulted
> in a compiler error.)
>
> In my googling the only other reference to protocols with primitive
> support was an unanswered question on this mailing list last November[1].
>  Hopefully my question gets a little more attention...
>
> (Pardon all these primitive type questions but I'm in the process of
> upgrading a 1.2 app to 1.3 and trying to convert some of our numeric heavy
> java code into clojure in the process.)
>
> Thanks,
> Ben
>
> 1. http://groups.google.com/**group/clojure/browse_thread/**
> thread/6015aacd6e8d0d20/**ccca98bea3970240
>

It's not currently supported. If you're interested in how to best implement
fast numeric code I suggest looking at test.benchmark.

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

[ANN] New Version of ClojureScript One

2012-01-25 Thread Brenton
We have released a new version of ClojureScript One.

The most significant changes are:

No more scripts! Everything now works through Leiningen. We have added
support for retrieveing git dependencies via Leiningen.

Allow connections to the REPL form remote machines.

See the change log:

https://github.com/brentonashworth/one/wiki/Change-Log

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


No support for primitive type returns within protocols (1.3)?

2012-01-25 Thread Ben Mabey

Hi again,

Is it possible to add primitive type hints to protocols (as the return 
type)?  My attempt below failed:


(definterface IPrimitiveTester
  (getType [^int x])
  (getType [^long x])
  (getType [^float x])
  (getType [^double x])
  (getType [^Object x]))

(deftype PrimitiveTester []
  IPrimitiveTester
  (getType [this ^int x] :int)
  (getType [this ^long x] :long)
  (getType [this ^float x] :float)
  (getType [this ^double x] :double)
  (getType [this ^Object x] :object))


(defmacro primitive-type [x]
  `(.getType (PrimitiveTester.) ~x))

(defmacro pt [x]
  `(.getType (PrimitiveTester.) ~x))

(defprotocol Foo
  (bar [foo]))

(deftype Dog []
  Foo
  (bar ^double [_] 42.0))

(pt (bar (Dog.))) ; => :object

(I also tried adding the hint to the protocol definition but that 
resulted in a compiler error.)


In my googling the only other reference to protocols with primitive 
support was an unanswered question on this mailing list last 
November[1].  Hopefully my question gets a little more attention...


(Pardon all these primitive type questions but I'm in the process of 
upgrading a 1.2 app to 1.3 and trying to convert some of our numeric 
heavy java code into clojure in the process.)


Thanks,
Ben

1. 
http://groups.google.com/group/clojure/browse_thread/thread/6015aacd6e8d0d20/ccca98bea3970240


--
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: ClojureScript One - Getting Started with ClojureScript

2012-01-25 Thread Raju Bitter
clojure.java.browse/open-url-in-swing is called a fallback method, and
then the ClojureScript app is not rendered correctly.

http://bit.ly/yPagHl

I'll see if I can create a workaround for that.

- Raju

-- 
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: ClojureScript One - Getting Started with ClojureScript

2012-01-25 Thread Raju Bitter
ClojureScript One is fantastic! Great work, thanks!

I just have one question, am running it on Ubuntu Linux. How can I set
the browser when I launch inferior/lisp script/cljs-repl? On Linux, a
Java based browser window is opened, and the page is not rendered
correctly?

Thanks again,
- Raju

-- 
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: Adding primitive type hints to anonymous functions

2012-01-25 Thread Tassilo Horn
Ben Mabey  writes:

> Am I missing something, or does the new primitive support only apply
> to bound functions?

On the one hand, the docs don't mention such a restriction, but on the
other hand, all examples given are always defn-defined.  I tried to look
into the compiler to find out, but that's not a component you understand
directly. So hopefully someone with a better knowledge of the compiler's
internals jumps in the discussion.

Bye,
Tassilo

-- 
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: Is this a bug? extending protocol on js/Object

2012-01-25 Thread Takahiro
>> How about using (extend-type default ...) ? Is it safe to use it?
> Oops, extend-type with default does work and it seems to work well.
This is what I am looking for! Thanks.

2012/1/26 David Nolen :
> On Fri, Jan 13, 2012 at 1:32 PM, Jozef Wagner 
> wrote:
>>
>> How about using (extend-type default ...) ? Is it safe to use it?
>>
>
> Oops, extend-type with default does work and it seems to work well.
>
> 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

-- 
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: Adding primitive type hints to anonymous functions

2012-01-25 Thread Ben Mabey

On 1/25/12 2:25 AM, Tassilo Horn wrote:

Hi again,

I think, I got it.  I wrote a little helper function to print the
metadata of a form:

--8<---cut here---start->8---
(use 'clojure.walk)
(defn print-meta
   ([form level]
  (prewalk
   (fn [x]
 (when-let [m (meta x)]
   (println "Level" level ":" x "=>" m)
   (print-meta m (inc level)))
 x)
   form))
   ([form]
  (print-meta form 0)))
--8<---cut here---end--->8---

Now see what happens:

--8<---cut here---start->8---
user>  (print-meta (macroexpand-all '(def b (fn ^foo [^bar x] ^baz x
Level 0 : x =>  {:tag bar}
Level 0 : x =>  {:tag baz}
(def b (fn* ([x] x)))
user>  (print-meta (macroexpand-all '(defn b ^foo [^bar x] ^baz x)))
Level 0 : b =>  {:arglists (quote ([x]))}
Level 1 : [x] =>  {:tag foo}
Level 1 : x =>  {:tag bar}
Level 0 : x =>  {:tag bar}
Level 0 : x =>  {:tag baz}
(def b (fn* ([x] x)))
--8<---cut here---end--->8---

So the return type metadata is actually added to the :arglist metadata
contents, so it's actually meta-metadata.  What you seem to have to do
is to make sure the :arglists metadata is there and reflects the type
hints on the actual function:

--8<---cut here---start->8---
user>  (def ^{:arglists '(^double [^double x])}
   with-def  (fn ^double [^double x] (+ x  0.5)))
#'user/with-def
user>  (pt (with-def 1))
:double
--8<---cut here---end--->8---

Well, that's not really obvious.  Maybe `def' could do a better job here
and build up a correct :arglists metadata value somehow...

Bye,
Tassilo


Hi Tassilo,
Thanks for doing the detective work!  I still have some questions 
though...  In my example I used def because I was able to reproduce the 
bug with def and it was the easiest way to show it. However, in practice 
these anonymous functions won't be bound to a root var (hence the 
anonymous part :) ). I would like to be able to write code like this:


(map-doubles (fn ^double [^double x] (+ x 0.5)) array)

I don't seem to be able to do that since the type hints are not put into 
effect without a var (it would seem):


(pt ((fn ^double [^double x] (+ x 0.5)) 1.0)) ; => :object

Not just put into effect, but not even stored on the function (as far as 
I can tell):


(meta  (fn ^double [^double x] (+ x 0.5))) ; => nil

I've tried adding the appropriate metadata onto the function (I'm 
stealing the metadata from our earlier with-defn):


(meta (with-meta (fn ^double [^double x] (+ x 0.5)) (select-keys (meta 
#'with-defn) [:arglists]))) ; => {:arglists ([x])}


I can verify that the arglist is tagged with the primitive just like it 
is with the var #'with-defn:


(defn arglist-tag [var]
  (-> var meta :arglists first meta :tag))

(arglist-tag #'with-defn) ; => double
(arglist-tag (with-meta (fn ^double [^double x] (+ x 0.5)) (select-keys 
(meta #'with-defn) [:arglists])))A ; => double


Sadly, even with the arglist meta-metadata boxing is still occurring:

(pt ((with-meta (fn ^double [^double x] (+ x 0.5)) (select-keys (meta 
#'with-defn) [:arglists])) 1.0)) ; => object


It is probably obvious that this would not work to someone who 
understands clojure's implementation, but to me this was a surprise.  
From this I gather that type hints on vars are what clojure uses and 
type hints on the actual functions are ignored.


Am I missing something, or does the new primitive support only apply to 
bound functions?


-Ben

--
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: Is this a bug? extending protocol on js/Object

2012-01-25 Thread David Nolen
On Fri, Jan 13, 2012 at 1:32 PM, Jozef Wagner wrote:

> How about using (extend-type default ...) ? Is it safe to use it?
>
>
Oops, extend-type with default does work and it seems to work well.

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: Accessing vals in clojure.lang.PersistentVector

2012-01-25 Thread Rasmus Svensson
On Wed, Jan 25, 2012 at 10:45 AM, Simon Holgate  wrote:
> I've retrieved some data from my database which is returned as a
> clojure.lang.PersistentVector:
> org.psmsl.netcdf.core> res
> [{:name "BREST", :time #, :rlrdata 6882M} {:name
> "BREST", :time #, :rlrdata 6908M} {:name
> "BREST", :time #, :rlrdata 6873M}...{:name
> "BREST", :time #, :rlrdata 7140M} {:name
> "BREST", :time #, :rlrdata 7088M}]
> org.psmsl.netcdf.core> (class res)
> clojure.lang.PersistentVector
>
> I thought I should be able to do:
> (vals res)

> and
> org.psmsl.netcdf.core> (get res :time)
> returns nil
>
> What am I doing wrong?

>From what I can tell, you want to list the values and extract the
value associated with :time for a map. The problem is that res is not
a map, but a vector of maps. If you want to do these operations on
every map in the vector you can use the map function ("map" as in "to
map"):

(map vals res)

(map :time res)

In the last example I made use of the fact that keywords also work as
functions. (:some-keyword some-map) is the same as (get some-map
:some-keyword).

To play in the repl with the first value in the vector in the repl you
can extract it with nth or get:

user> (def res ...)
#'res
user> (def first-res (nth res 0))
#'first-res
user> (vals first-res)
...
user> (get first-res :time)
...

// raek

-- 
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: Accessing vals in clojure.lang.PersistentVector

2012-01-25 Thread Simon Holgate
Answering myself, I see that I need to do:
(vals (res 1))

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


Accessing vals in clojure.lang.PersistentVector

2012-01-25 Thread Simon Holgate
Hi,

I've retrieved some data from my database which is returned as a
clojure.lang.PersistentVector:
org.psmsl.netcdf.core> res
[{:name "BREST", :time #, :rlrdata 6882M} {:name
"BREST", :time #, :rlrdata 6908M} {:name
"BREST", :time #, :rlrdata 6873M}...{:name
"BREST", :time #, :rlrdata 7140M} {:name
"BREST", :time #, :rlrdata 7088M}]
org.psmsl.netcdf.core> (class res)
clojure.lang.PersistentVector

I thought I should be able to do:
(vals res)
but I get
clojure.lang.PersistentArrayMap cannot be cast to java.util.Map$Entry
and
org.psmsl.netcdf.core> (get res :time)
returns nil

What am I doing wrong?

Thanks,

Simon

-- 
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: Adding primitive type hints to anonymous functions

2012-01-25 Thread Tassilo Horn
Hi again,

I think, I got it.  I wrote a little helper function to print the
metadata of a form:

--8<---cut here---start->8---
(use 'clojure.walk)
(defn print-meta
  ([form level]
 (prewalk
  (fn [x]
(when-let [m (meta x)]
  (println "Level" level ":" x "=>" m)
  (print-meta m (inc level)))
x)
  form))
  ([form]
 (print-meta form 0)))
--8<---cut here---end--->8---

Now see what happens:

--8<---cut here---start->8---
user> (print-meta (macroexpand-all '(def b (fn ^foo [^bar x] ^baz x
Level 0 : x => {:tag bar}
Level 0 : x => {:tag baz}
(def b (fn* ([x] x)))
user> (print-meta (macroexpand-all '(defn b ^foo [^bar x] ^baz x)))
Level 0 : b => {:arglists (quote ([x]))}
Level 1 : [x] => {:tag foo}
Level 1 : x => {:tag bar}
Level 0 : x => {:tag bar}
Level 0 : x => {:tag baz}
(def b (fn* ([x] x)))
--8<---cut here---end--->8---

So the return type metadata is actually added to the :arglist metadata
contents, so it's actually meta-metadata.  What you seem to have to do
is to make sure the :arglists metadata is there and reflects the type
hints on the actual function:

--8<---cut here---start->8---
user> (def ^{:arglists '(^double [^double x])}
   with-def  (fn ^double [^double x] (+ x  0.5)))
#'user/with-def
user> (pt (with-def 1))
:double
--8<---cut here---end--->8---

Well, that's not really obvious.  Maybe `def' could do a better job here
and build up a correct :arglists metadata value somehow...

Bye,
Tassilo

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