"closed" maps / reducing runtime errors due to mistyped keywords

2011-04-21 Thread Christian Schuhegger
I am taking up a discussion from 2010:
https://groups.google.com/group/clojure/browse_frm/thread/60dff89149c3d2e6/

I would prefer if it would be possible to define "closed maps", e.g.
maps that allow only a certain set of keywords, both for get and
"set" (like in assoc, assoc-in, update-in, ...). It would be nice if
there would be an option on defrecord to mark the map as "closed".

I imagine that this would have some runtime penalty, because for every
access it has to be verified if the key is a valid one. I understand
that. Perhaps in that case the language could react differently based
on the value of a dynamic var (*check-closed-defrecrod-p*) that can be
set when the unit tests are run and could be false by default.

I guess this topic was already discussed several times. Could somebody
point me to previous discussions and their outcome?
I've found in addition the following thread where the idea of "safe
maps" was discussed to some extent:
https://groups.google.com/group/clojure/browse_frm/thread/134642cc76de17f7/

Thanks,
Christian

-- 
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: lein deps error, please help...

2011-04-21 Thread uMany
Thank you very much Mr Hugo.
I'm now able to continue with my learning.
Hope to be helping people here soon :-)

-- 
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: lein deps error, please help...

2011-04-21 Thread Hugo Duncan

On Thu, 21 Apr 2011 20:24:15 -0400, uMany  wrote:


when I try lein deps at a test-project
with this
I got this long error message:
tmp/test-project$ lein deps
Downloading:
org/clojure/clojure/1.2.0-master-SNAPSHOT/clojure-1.2.0-master-SNAPSHOT.jar
from clojure-snapshots
Downloading:
org/clojure/clojure/1.2.0-master-SNAPSHOT/clojure-1.2.0-master-SNAPSHOT.jar
from clojars
Downloading:
org/clojure/clojure-contrib/1.2.0-SNAPSHOT/clojure-contrib-1.2.0-SNAPSHOT.jar
from clojure-snapshots
Downloading:
org/clojure/clojure-contrib/1.2.0-SNAPSHOT/clojure-contrib-1.2.0-SNAPSHOT.jar
from clojars
An error has occurred while processing the Maven artifact tasks.
 Diagnosis:


It looks like you have dependencies on clojure-1.2.0-SNAPSHOT and  
clojure-contrib-1.2.0-SNAPSHOT.  Try removing the "-SNAPSHOT" from these  
in your project.clj file.


In the maven/jar world a SNAPSHOT refers to a interim, development version  
of jar, and can disappear at any time.  Clojure 1.2 has been available as  
a release version for quite a while now.


--
Hugo Duncan

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


lein deps error, please help...

2011-04-21 Thread uMany
Hi,

I'm learning to program Common Lisp and Clojure all at once. I just like 
them a lot. I like them so much that I am also using Emacs, which is like a 
pain in the a.. for a total newbie.
Any way, I installed
sun-java6-jdk
ant
maven (3.0.2)
clojure-contrib
jline
emacs
slime
clojure-mode
leiningen

exported all the paths, make all the configuration stuf
and so far everything seems to work, but...

when I try lein deps at a test-project
with this 
I got this long error message:
tmp/test-project$ lein deps
Downloading: 
org/clojure/clojure/1.2.0-master-SNAPSHOT/clojure-1.2.0-master-SNAPSHOT.jar 
from clojure-snapshots
Downloading: 
org/clojure/clojure/1.2.0-master-SNAPSHOT/clojure-1.2.0-master-SNAPSHOT.jar 
from clojars
Downloading: 
org/clojure/clojure-contrib/1.2.0-SNAPSHOT/clojure-contrib-1.2.0-SNAPSHOT.jar 
from clojure-snapshots
Downloading: 
org/clojure/clojure-contrib/1.2.0-SNAPSHOT/clojure-contrib-1.2.0-SNAPSHOT.jar 
from clojars
An error has occurred while processing the Maven artifact tasks.
 Diagnosis:

Unable to resolve artifact: Missing:
--
1) org.clojure:clojure:jar:1.2.0-master-SNAPSHOT

  Try downloading the file manually from the project website.

  Then, install it using the command: 
  mvn install:install-file -DgroupId=org.clojure -DartifactId=clojure 
-Dversion=1.2.0-master-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file 
there: 
  mvn deploy:deploy-file -DgroupId=org.clojure -DartifactId=clojure 
-Dversion=1.2.0-master-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file 
-Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
   1) org.apache.maven:super-pom:jar:2.0
   2) org.clojure:clojure:jar:1.2.0-master-SNAPSHOT

2) org.clojure:clojure-contrib:jar:1.2.0-SNAPSHOT

  Try downloading the file manually from the project website.

  Then, install it using the command: 
  mvn install:install-file -DgroupId=org.clojure 
-DartifactId=clojure-contrib -Dversion=1.2.0-SNAPSHOT -Dpackaging=jar 
-Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file 
there: 
  mvn deploy:deploy-file -DgroupId=org.clojure 
-DartifactId=clojure-contrib -Dversion=1.2.0-SNAPSHOT -Dpackaging=jar 
-Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
   1) org.apache.maven:super-pom:jar:2.0
   2) org.clojure:clojure-contrib:jar:1.2.0-SNAPSHOT

--
2 required artifacts are missing.

for artifact: 
  org.apache.maven:super-pom:jar:2.0

from the specified remote repositories:
  clojure (http://build.clojure.org/releases),
  clojars (http://clojars.org/repo/),
  clojure-snapshots (http://build.clojure.org/snapshots),
  central (http://repo1.maven.org/maven2)



Exception in thread "main" Unable to resolve artifact: Missing:
--
1) org.clojure:clojure:jar:1.2.0-master-SNAPSHOT

  Try downloading the file manually from the project website.

  Then, install it using the command: 
  mvn install:install-file -DgroupId=org.clojure -DartifactId=clojure 
-Dversion=1.2.0-master-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file 
there: 
  mvn deploy:deploy-file -DgroupId=org.clojure -DartifactId=clojure 
-Dversion=1.2.0-master-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file 
-Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
   1) org.apache.maven:super-pom:jar:2.0
   2) org.clojure:clojure:jar:1.2.0-master-SNAPSHOT

2) org.clojure:clojure-contrib:jar:1.2.0-SNAPSHOT

  Try downloading the file manually from the project website.

  Then, install it using the command: 
  mvn install:install-file -DgroupId=org.clojure 
-DartifactId=clojure-contrib -Dversion=1.2.0-SNAPSHOT -Dpackaging=jar 
-Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file 
there: 
  mvn deploy:deploy-file -DgroupId=org.clojure 
-DartifactId=clojure-contrib -Dversion=1.2.0-SNAPSHOT -Dpackaging=jar 
-Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
   1) org.apache.maven:super-pom:jar:2.0
   2) org.clojure:clojure-contrib:jar:1.2.0-SNAPSHOT

--
2 required artifacts are missing.

for artifact: 
  org.apache.maven:super-pom:jar:2.0

from the specified remote repositories:
  clojure (http://build.clojure.org/releases),
  clojars (http://clojars.org/repo/),
  clojure-snapshots (http://build.clojure.org/snapshots),
  central (http://repo1.maven.org/maven2)

 (NO_SOURCE_FILE:0)
at clojure.lang.Compiler.eval(Compiler.java:5440)
at clojure.lang.Compiler.eval(Compiler.java:5391)
at clojure.core$eval.invoke(core.clj:2382)
at clojure.main$eval_opt.invoke(main.clj:235)
at clojure.main$initialize.invoke(main.clj:254)
at clojure.main$script_opt.invoke(main.clj:270)
at clojure.main$main.doInvoke(main.clj:354)
at clojure.lang.RestFn.invoke(RestFn.java:458)
at clojure.lang.Var.invoke(Var.java:377)
at clojure.lang.AFn.applyToHelper(AFn.java:174)
at clojure

Re: Two types of special symbol

2011-04-21 Thread Kevin Downey
the current compiler doesn't namespace qualify special forms (forms
which are built into the compiler) but somethings that the
documentation lists as "special forms" are infact macros defined in
clojure.core based on the real special forms provided by the compiler.
macros are namespace qualified so unless you use the fully qualified
name(clojure.core/let) or :use/use them then they aren't available.
this difference is kind of unfortunate, and the design notes on a
compiler rewrite mention changing things so the forms directly
supported by the compiler are also namespace qualified and live in
clojure.core

On Thu, Apr 21, 2011 at 12:24 PM, Simon Katz  wrote:
> Hi.
>
> (In case it makes a difference, I'm using Clojure 1.2.)
>
> If one creates a new namespace using in-ns, the new namespace
> does not refer to clojure.core, as explained at
> http://clojure.org/namespaces.
>
> I noticed one can use certain special forms in a namespace
> created using in-ns, but not others:
>  _
> |
> | user> (in-ns 'my-new-ns)
> | #
> |
> | my-new-ns> (quote a)
> | a
> |
> | my-new-ns> (def x 42)
> | #'my-new-ns/x
> |
> | my-new-ns> (let [a 42] a)
> | ;; Evaluation aborted. Unable to resolve symbol: let in this context
> |
> | my-new-ns> (fn [] 42)
> | ;; Evaluation aborted. Unable to resolve symbol: fn in this context
> |_
>
> That puzzled me.
>
> In the process of trying to understand, I came across a mention
> of clojure.lang.Compiler/specials (a map with symbols as its keys)
> at 
> http://stackoverflow.com/questions/3159836/is-there-a-way-to-get-a-collection-of-clojure-special-forms-programatically
>  _
> |
> | user> (keys clojure.lang.Compiler/specials)
> | ;; => (deftype* new quote & var set! monitor-enter recur .
> |        case* clojure.core/import* reify* do fn* throw
> |        monitor-exit letfn* finally let* loop* try catch if
> |        def)
> |_
>
> So it seems that there are two kinds of special symbol.  I'll
> refer to them as implementation specials and documented specials:
>  - implementation specials
>    those that are keys in the clojure.lang.Compiler/specials
>    map
>  - documented specials
>    those that are documented as being special at
>    http://clojure.org/special_forms.
> (Note that some symbols are of both kinds.)
>
> I assume that documented specials that are not implementation
> specials are implemented as macros. (And the post I mentioned
> above at stackoverflow.com says so.)
>
> Here's some investigation of these two kinds of special symbol:
>  _
> |
> | user> (def implementation-specials
> |            (keys clojure.lang.Compiler/specials))
> | #'user/implementation-specials
> |
> | user> (def documented-specials
> |            '(def if do let quote var fn loop recur throw try
> |              monitor-enter monitor-exit . new set!))
> | #'user/documented-specials
> |
> | user> (defn symbol-info [symbol]
> |         [(special-symbol? symbol)
> |          (= (resolve symbol) nil)
> |          symbol])
> | #'user/symbol-info
> |
> | user> (pprint (map symbol-info implementation-specials))
> | ([true true deftype*]
> |  [true true new]
> |  [true true quote]
> |  [true true &]
> |  [true true var]
> |  [true true set!]
> |  [true true monitor-enter]
> |  [true true recur]
> |  [true true .]
> |  [true true case*]
> |  [true true clojure.core/import*]
> |  [true true reify*]
> |  [true true do]
> |  [true true fn*]
> |  [true true throw]
> |  [true true monitor-exit]
> |  [true true letfn*]
> |  [true true finally]
> |  [true true let*]
> |  [true true loop*]
> |  [true true try]
> |  [true true catch]
> |  [true true if]
> |  [true true def])
> | nil
> |
> | user> (pprint (map symbol-info documented-specials))
> | ([true true def]
> |  [true true if]
> |  [true true do]
> |  [false false let]
> |  [true true quote]
> |  [true true var]
> |  [false false fn]
> |  [false false loop]
> |  [true true recur]
> |  [true true throw]
> |  [true true try]
> |  [true true monitor-enter]
> |  [true true monitor-exit]
> |  [true true .]
> |  [true true new]
> |  [true true set!])
> | nil
> |_
>
> There are a few interesting things here:
>
>  - special-symbol? returns true for implementation specials
>    (actually not surprising when you look at the implementation
>    of special-symbol?, but perhaps surprising if you have only
>    read http://clojure.org/namespaces and the documentation of
>    special-symbol? which says "Returns true if [the argument]
>    names a special form").
>
>  - Calling resolve on an implementation special gives nil.
>
>  - In a namespace created using in-ns (such as my-new-ns above)
>    one is able to make use of implementation specials.
>    Implementation specials seem to bypass the normal
>    resolution process:
>    - defn is not an 

ANN: pallet.thread-expr, a macro lib for use with -> argument threading

2011-04-21 Thread Hugo Duncan
By popular demand (well at least two requests), pallet.thread-expr is now  
an independent lib, extracted from pallet.


The library provides a number of macros for use within a -> expression.

A couple of examples:

(-> 2
  (arg-> [x]
(* (inc x
 => 6

(-> 1
  (for-> [x [1 2 3]]
(+ x)))
 => 7

Github: https://github.com/pallet/thread-expr
Autodoc:  http://pallet.github.com/thread-expr/autodoc/index.html
Marginalia: http://pallet.github.com/thread-expr/marginalia/uberdoc.html

--
Hugo Duncan

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


Two types of special symbol

2011-04-21 Thread Simon Katz
Hi.

(In case it makes a difference, I'm using Clojure 1.2.)

If one creates a new namespace using in-ns, the new namespace
does not refer to clojure.core, as explained at
http://clojure.org/namespaces.

I noticed one can use certain special forms in a namespace
created using in-ns, but not others:
 _
|
| user> (in-ns 'my-new-ns)
| #
|
| my-new-ns> (quote a)
| a
|
| my-new-ns> (def x 42)
| #'my-new-ns/x
|
| my-new-ns> (let [a 42] a)
| ;; Evaluation aborted. Unable to resolve symbol: let in this context
|
| my-new-ns> (fn [] 42)
| ;; Evaluation aborted. Unable to resolve symbol: fn in this context
|_

That puzzled me.

In the process of trying to understand, I came across a mention
of clojure.lang.Compiler/specials (a map with symbols as its keys)
at 
http://stackoverflow.com/questions/3159836/is-there-a-way-to-get-a-collection-of-clojure-special-forms-programatically
 _
|
| user> (keys clojure.lang.Compiler/specials)
| ;; => (deftype* new quote & var set! monitor-enter recur .
|case* clojure.core/import* reify* do fn* throw
|monitor-exit letfn* finally let* loop* try catch if
|def)
|_

So it seems that there are two kinds of special symbol.  I'll
refer to them as implementation specials and documented specials:
  - implementation specials
those that are keys in the clojure.lang.Compiler/specials
map
  - documented specials
those that are documented as being special at
http://clojure.org/special_forms.
(Note that some symbols are of both kinds.)

I assume that documented specials that are not implementation
specials are implemented as macros. (And the post I mentioned
above at stackoverflow.com says so.)

Here's some investigation of these two kinds of special symbol:
 _
|
| user> (def implementation-specials
|(keys clojure.lang.Compiler/specials))
| #'user/implementation-specials
|
| user> (def documented-specials
|'(def if do let quote var fn loop recur throw try
|  monitor-enter monitor-exit . new set!))
| #'user/documented-specials
|
| user> (defn symbol-info [symbol]
| [(special-symbol? symbol)
|  (= (resolve symbol) nil)
|  symbol])
| #'user/symbol-info
|
| user> (pprint (map symbol-info implementation-specials))
| ([true true deftype*]
|  [true true new]
|  [true true quote]
|  [true true &]
|  [true true var]
|  [true true set!]
|  [true true monitor-enter]
|  [true true recur]
|  [true true .]
|  [true true case*]
|  [true true clojure.core/import*]
|  [true true reify*]
|  [true true do]
|  [true true fn*]
|  [true true throw]
|  [true true monitor-exit]
|  [true true letfn*]
|  [true true finally]
|  [true true let*]
|  [true true loop*]
|  [true true try]
|  [true true catch]
|  [true true if]
|  [true true def])
| nil
|
| user> (pprint (map symbol-info documented-specials))
| ([true true def]
|  [true true if]
|  [true true do]
|  [false false let]
|  [true true quote]
|  [true true var]
|  [false false fn]
|  [false false loop]
|  [true true recur]
|  [true true throw]
|  [true true try]
|  [true true monitor-enter]
|  [true true monitor-exit]
|  [true true .]
|  [true true new]
|  [true true set!])
| nil
|_

There are a few interesting things here:

  - special-symbol? returns true for implementation specials
(actually not surprising when you look at the implementation
of special-symbol?, but perhaps surprising if you have only
read http://clojure.org/namespaces and the documentation of
special-symbol? which says "Returns true if [the argument]
names a special form").

  - Calling resolve on an implementation special gives nil.

  - In a namespace created using in-ns (such as my-new-ns above)
one is able to make use of implementation specials.
Implementation specials seem to bypass the normal
resolution process:
- defn is not an implementation special:
user> (resolve 'defn)
#'clojure.core/defn
- def is an implementation special:
user> (resolve 'def)
nil

Well, that's probably enough wittering.

Any comments?

And my main question...
Is any of this stuff documented? (Perhaps there's other related
stuff that it would be good to know.)

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: Resolution of in-ns in a namespace that does not refer clojure.core

2011-04-21 Thread Simon Katz
OK, thanks, will do.

Simon

On Thu, Apr 21, 2011 at 20:01, Stuart Halloway wrote:

> Let's say that little surprises are not a design objective. :-)
>
> Please do follow up with additional questions as you have them.
>
> Stu
>
> Hi Stu.
>
> Thanks.  That makes sense.
>
> Is this special-casing documented somewhere, or is it something one can
> only
> discover by playing?  More generally, I'm wondering whether I'm likely to
> come across other areas with little surprises as I learn more.  An example:
> I've been exploring special symbols, and it seems to me that the
> documentation doesn't quite match behaviour, or at least the documentation
> doesn't say all that it might say -- I might post about that separately.
>
> Simon
>
>
> On Thu, Apr 21, 2011 at 18:23, Stuart Halloway 
> wrote:
>
>> Hi Simon,
>>
>> in-ns and ns are special cased for convenience. Usually in-ns is used to
>> enter a namespace that has already been loaded, so that core names are
>> available. For example:
>>
>> ;; in a file
>> (ns my.ns)
>>
>> ;; stuff
>>
>> (comment
>>   (require 'my.ns)
>>   (in-ns 'my.ns)
>>
>>   ;; tests
>> )
>>
>>
>> Stu
>>
>> Hi.
>>
>> I'm learning Clojure, currently using Clojure 1.2.
>>
>> http://clojure.org/namespaces when talking about creating
>> namespaces says:
>>  At the Repl it's best to use in-ns, in which case the new
>>  namespace will contain mappings only for the classnames
>>  in java.lang. In order to access the names from the
>>  clojure.core namespace you must execute
>>  (clojure.core/refer 'clojure.core).
>>
>> Given the above, in the following...
>> _
>> |
>> | user> (in-ns 'my-new-ns)
>> | #
>> |
>> | my-new-ns> (in-ns 'user)
>> | #
>> |_
>>
>> ...how does the second in-ns get resolved?
>> For comparison, use of most other operators from my-new-ns gives
>> resolution errors. For example:
>> _
>> |
>> | my-new-ns> (+ 1 2)
>> | ;; Evaluation aborted. Unable to resolve symbol: + in this context
>> |_
>>
>> --
>> 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
>>
>>
>>  Stuart Halloway
>> Clojure/core
>> http://clojure.com
>>
>>
>> --
>> 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
>
>
> Stuart Halloway
> Clojure/core
> http://clojure.com
>
>  --
> 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: Meta-circular STM for teaching purposes

2011-04-21 Thread Devin Walters
+1

Thanks so much.  Looking forward to digging into the code this evening.

Any chance you will have any online course materials for public consumption?

Thanks again,
Sent via mobile

On Apr 21, 2011, at 1:25 PM, Ambrose Bonnaire-Sergeant 
 wrote:

> This is great, thanks for sharing!
> 
> Ambrose
> 
> On Thu, Apr 21, 2011 at 10:57 PM, Tom Van Cutsem  wrote:
> The following might be of interest to Clojurians:
> 
> https://github.com/tvcutsem/stm-in-clojure is a meta-circular implementation 
> of STM in Clojure. It was created purely for educational purposes (to allow 
> people to better understand STM by reading a Clojure implementation, without 
> having to descend into the Java implementation). The simplest meta-circular 
> MVCC implementation weighs in at less than 200 LOC.
> 
> I use this implementation for teaching. There's a set of slides that 
> accompany this code at http://www.slideshare.net/tvcutsem/stm-inclojure
> 
> I welcome any feedback on this implementation. I'm fairly new to Clojure 
> myself, so comments on style are also appreciated. For those "into" Clojure's 
> real STM implementation, pointing out any aspects of my meta-circular 
> implementation that may be misleading as compared to the built-in STM would 
> be particularly helpful.
> 
> Kind regards,
> Tom
> 
> 2010/11/2 Tom Van Cutsem 
> Hi,
> 
> In a couple of months I will teach a new course on concurrent/parallel 
> programming at the University of Brussels. I will use Clojure for a large 
> part of the course. I primarily want the students to learn how to make 
> effective use of the STM as Clojure programmers, but I would also like to 
> expose them to some "under the hood" implementation details. One option would 
> be to dive into the actual Java implementation of Clojure's STM, but my fear 
> is that this will be too complex. Another option I've been thinking of is to 
> write a simple, didactic STM in Clojure itself (following the SICP 
> meta-circular interpreters tradition). It goes without saying that high 
> performance is not the goal here. Rather, it should help students to grasp 
> atomicity, isolation, interactions between readers/writers, the differences 
> between alter and commute, etc.
> 
> My questions to the list:
> - has anyone already experimented with a toy STM in Clojure for didactic 
> purposes?
> - what would be a good resource to start such a design from? (my current plan 
> is to start from )
> 
> Thanks,
> Tom
> 
> -- 
> 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

-- 
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: Resolution of in-ns in a namespace that does not refer clojure.core

2011-04-21 Thread Stuart Halloway
Let's say that little surprises are not a design objective. :-)

Please do follow up with additional questions as you have them.

Stu

> Hi Stu.
> 
> Thanks.  That makes sense.
> 
> Is this special-casing documented somewhere, or is it something one can only
> discover by playing?  More generally, I'm wondering whether I'm likely to
> come across other areas with little surprises as I learn more.  An example:
> I've been exploring special symbols, and it seems to me that the
> documentation doesn't quite match behaviour, or at least the documentation
> doesn't say all that it might say -- I might post about that separately.
> 
> Simon
> 
> 
> On Thu, Apr 21, 2011 at 18:23, Stuart Halloway  
> wrote:
> Hi Simon,
> 
> in-ns and ns are special cased for convenience. Usually in-ns is used to 
> enter a namespace that has already been loaded, so that core names are 
> available. For example:
> 
> ;; in a file
> (ns my.ns)
> 
> ;; stuff
> 
> (comment
>   (require 'my.ns)
>   (in-ns 'my.ns)
> 
>   ;; tests
> )
> 
> 
> Stu
> 
>> Hi.
>> 
>> I'm learning Clojure, currently using Clojure 1.2.
>> 
>> http://clojure.org/namespaces when talking about creating
>> namespaces says:
>>  At the Repl it's best to use in-ns, in which case the new
>>  namespace will contain mappings only for the classnames
>>  in java.lang. In order to access the names from the
>>  clojure.core namespace you must execute
>>  (clojure.core/refer 'clojure.core).
>> 
>> Given the above, in the following...
>> _
>> |
>> | user> (in-ns 'my-new-ns)
>> | #
>> |
>> | my-new-ns> (in-ns 'user)
>> | #
>> |_
>> 
>> ...how does the second in-ns get resolved?
>> For comparison, use of most other operators from my-new-ns gives
>> resolution errors. For example:
>> _
>> |
>> | my-new-ns> (+ 1 2)
>> | ;; Evaluation aborted. Unable to resolve symbol: + in this context
>> |_
>> 
>> -- 
>> 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
> 
> Stuart Halloway
> Clojure/core
> http://clojure.com
> 
> 
> -- 
> 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

Stuart Halloway
Clojure/core
http://clojure.com

-- 
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: Resolution of in-ns in a namespace that does not refer clojure.core

2011-04-21 Thread Simon Katz
Hi Stu.

Thanks.  That makes sense.

Is this special-casing documented somewhere, or is it something one can only
discover by playing?  More generally, I'm wondering whether I'm likely to
come across other areas with little surprises as I learn more.  An example:
I've been exploring special symbols, and it seems to me that the
documentation doesn't quite match behaviour, or at least the documentation
doesn't say all that it might say -- I might post about that separately.

Simon


On Thu, Apr 21, 2011 at 18:23, Stuart Halloway wrote:

> Hi Simon,
>
> in-ns and ns are special cased for convenience. Usually in-ns is used to
> enter a namespace that has already been loaded, so that core names are
> available. For example:
>
> ;; in a file
> (ns my.ns)
>
> ;; stuff
>
> (comment
>   (require 'my.ns)
>   (in-ns 'my.ns)
>
>   ;; tests
> )
>
>
> Stu
>
> Hi.
>
> I'm learning Clojure, currently using Clojure 1.2.
>
> http://clojure.org/namespaces when talking about creating
> namespaces says:
>  At the Repl it's best to use in-ns, in which case the new
>  namespace will contain mappings only for the classnames
>  in java.lang. In order to access the names from the
>  clojure.core namespace you must execute
>  (clojure.core/refer 'clojure.core).
>
> Given the above, in the following...
> _
> |
> | user> (in-ns 'my-new-ns)
> | #
> |
> | my-new-ns> (in-ns 'user)
> | #
> |_
>
> ...how does the second in-ns get resolved?
> For comparison, use of most other operators from my-new-ns gives
> resolution errors. For example:
> _
> |
> | my-new-ns> (+ 1 2)
> | ;; Evaluation aborted. Unable to resolve symbol: + in this context
> |_
>
> --
> 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
>
>
> Stuart Halloway
> Clojure/core
> http://clojure.com
>
>  --
> 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: Meta-circular STM for teaching purposes

2011-04-21 Thread Ambrose Bonnaire-Sergeant
This is great, thanks for sharing!

Ambrose

On Thu, Apr 21, 2011 at 10:57 PM, Tom Van Cutsem  wrote:

> The following might be of interest to Clojurians:
>
> https://github.com/tvcutsem/stm-in-clojure is a meta-circular
> implementation of STM in Clojure. It was created purely for educational
> purposes (to allow people to better understand STM by reading a Clojure
> implementation, without having to descend into the Java implementation). The
> simplest meta-circular MVCC implementation weighs in at less than 200 LOC.
>
> I use this implementation for teaching. There's a set of slides that
> accompany this code at http://www.slideshare.net/tvcutsem/stm-inclojure
>
> I welcome any feedback on this implementation. I'm fairly new to Clojure
> myself, so comments on style are also appreciated. For those "into"
> Clojure's real STM implementation, pointing out any aspects of my
> meta-circular implementation that may be misleading as compared to the
> built-in STM would be particularly helpful.
>
> Kind regards,
> Tom
>
> 2010/11/2 Tom Van Cutsem 
>
>> Hi,
>>
>> In a couple of months I will teach a new course on concurrent/parallel
>> programming at the University of Brussels. I will use Clojure for a large
>> part of the course. I primarily want the students to learn how to make
>> effective use of the STM as Clojure programmers, but I would also like to
>> expose them to some "under the hood" implementation details. One option
>> would be to dive into the actual Java implementation of Clojure's STM, but
>> my fear is that this will be too complex. Another option I've been thinking
>> of is to write a simple, didactic STM in Clojure itself (following the SICP
>> meta-circular interpreters tradition). It goes without saying that high
>> performance is not the goal here. Rather, it should help students to grasp
>> atomicity, isolation, interactions between readers/writers, the differences
>> between alter and commute, etc.
>>
>> My questions to the list:
>> - has anyone already experimented with a toy STM in Clojure for didactic
>> purposes?
>> - what would be a good resource to start such a design from? (my current
>> plan is to start from )
>>
>> Thanks,
>> Tom
>>
>
>  --
> 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: Resolution of in-ns in a namespace that does not refer clojure.core

2011-04-21 Thread Stuart Halloway
Hi Simon,

in-ns and ns are special cased for convenience. Usually in-ns is used to enter 
a namespace that has already been loaded, so that core names are available. For 
example:

;; in a file
(ns my.ns)

;; stuff

(comment
  (require 'my.ns)
  (in-ns 'my.ns)

  ;; tests
)


Stu

> Hi.
> 
> I'm learning Clojure, currently using Clojure 1.2.
> 
> http://clojure.org/namespaces when talking about creating
> namespaces says:
>  At the Repl it's best to use in-ns, in which case the new
>  namespace will contain mappings only for the classnames
>  in java.lang. In order to access the names from the
>  clojure.core namespace you must execute
>  (clojure.core/refer 'clojure.core).
> 
> Given the above, in the following...
> _
> |
> | user> (in-ns 'my-new-ns)
> | #
> |
> | my-new-ns> (in-ns 'user)
> | #
> |_
> 
> ...how does the second in-ns get resolved?
> For comparison, use of most other operators from my-new-ns gives
> resolution errors. For example:
> _
> |
> | my-new-ns> (+ 1 2)
> | ;; Evaluation aborted. Unable to resolve symbol: + in this context
> |_
> 
> -- 
> 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

Stuart Halloway
Clojure/core
http://clojure.com

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

Resolution of in-ns in a namespace that does not refer clojure.core

2011-04-21 Thread Simon Katz
Hi.

I'm learning Clojure, currently using Clojure 1.2.

http://clojure.org/namespaces when talking about creating
namespaces says:
  At the Repl it's best to use in-ns, in which case the new
  namespace will contain mappings only for the classnames
  in java.lang. In order to access the names from the
  clojure.core namespace you must execute
  (clojure.core/refer 'clojure.core).

Given the above, in the following...
 _
|
| user> (in-ns 'my-new-ns)
| #
|
| my-new-ns> (in-ns 'user)
| #
|_

...how does the second in-ns get resolved?
For comparison, use of most other operators from my-new-ns gives
resolution errors. For example:
 _
|
| my-new-ns> (+ 1 2)
| ;; Evaluation aborted. Unable to resolve symbol: + in this context
|_

-- 
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: Emacs 23 issues.

2011-04-21 Thread Vincent Liard
Hi Manoj,

> "unreadable message: (:emacs-rex (swank:autodoc (quote ("d" swank::
> %cursor-marker%)) :print-right-margin 132) "user" :repl-thread 4)
> exception in read loop
> java.lang.RuntimeException: java.lang.Exception: Invalid token:
> swank::"

I have experienced a similar (or the same) problem. I can't find back
the appropriate reference, but there is a bug with autodoc in
swank-clojure.

Try adding (setq slime-use-autodoc-mode nil) to your .emacs

Vincent

-- 
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: Meta-circular STM for teaching purposes

2011-04-21 Thread Tom Van Cutsem
The following might be of interest to Clojurians:

https://github.com/tvcutsem/stm-in-clojure is a meta-circular implementation
of STM in Clojure. It was created purely for educational purposes (to allow
people to better understand STM by reading a Clojure implementation, without
having to descend into the Java implementation). The simplest meta-circular
MVCC implementation weighs in at less than 200 LOC.

I use this implementation for teaching. There's a set of slides that
accompany this code at http://www.slideshare.net/tvcutsem/stm-inclojure

I welcome any feedback on this implementation. I'm fairly new to Clojure
myself, so comments on style are also appreciated. For those "into"
Clojure's real STM implementation, pointing out any aspects of my
meta-circular implementation that may be misleading as compared to the
built-in STM would be particularly helpful.

Kind regards,
Tom

2010/11/2 Tom Van Cutsem 

> Hi,
>
> In a couple of months I will teach a new course on concurrent/parallel
> programming at the University of Brussels. I will use Clojure for a large
> part of the course. I primarily want the students to learn how to make
> effective use of the STM as Clojure programmers, but I would also like to
> expose them to some "under the hood" implementation details. One option
> would be to dive into the actual Java implementation of Clojure's STM, but
> my fear is that this will be too complex. Another option I've been thinking
> of is to write a simple, didactic STM in Clojure itself (following the SICP
> meta-circular interpreters tradition). It goes without saying that high
> performance is not the goal here. Rather, it should help students to grasp
> atomicity, isolation, interactions between readers/writers, the differences
> between alter and commute, etc.
>
> My questions to the list:
> - has anyone already experimented with a toy STM in Clojure for didactic
> purposes?
> - what would be a good resource to start such a design from? (my current
> plan is to start from )
>
> Thanks,
> Tom
>

-- 
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: Future of clojure.contrib.core/-?> macro

2011-04-21 Thread Ivan Koblik
Hi Paul,

Thanks, good to know. Sorry for the misleading email.

Cheers,
Ivan.


On 21 April 2011 08:47, pmbauer  wrote:

> Ivan,
> clojure/core use a different workflow than is typical for github
> projects.
> The github readme doesn't indicate, but you may find the process here:
>
> http://clojure.org/contributing
> http://clojure.org/patches
>
> Cheers,
> pm
>
> On Apr 20, 1:44 am, Ivan Koblik  wrote:
> > Hello Konrad,
> >
> > Git workflow is a little bit different. You don't really need commit
> rights
> > to contribute. I found a rather nice explanation of Git workflow here:
> http://www.eqqon.com/index.php/Collaborative_Github_Workflow
> >
> > Hope it helps.
> >
> > Cheers,
> > Ivan.
> >
> > On 19 April 2011 16:40, Konrad Hinsen 
> wrote:
> >
> >
> >
> > > On 19 Apr, 2011, at 13:56 , Stuart Halloway wrote:
> >
> > > >> Concerning my own modules in old contrib, there are three that I use
> > > myself and that I am planning to maintain, independently of where they
> will
> > > end up:
> > > >> - clojure.contrib.monads
> > > >> - clojure.contrib.macro-utils
> > > >> - clojure.contrib.generic
> >
> > > > There is an empty repos already waiting for your macro utils:
> > >https://github.com/clojure/tools.macro
> >
> > > Great, thanks, I'll start with that one. Monads depend on it anyway.
> But I
> > > need commit permissions, which I probably don't have, but I don't even
> know
> > > how to find out without trying to do a commit. Can you please add me in
> the
> > > right place? My github account is khinsen.
> >
> > > > I have put some suggested names for the other new projects at
> > >http://dev.clojure.org/display/design/Contrib+Library+Names. Please
> review
> > > and comment, either there or here on the list.
> >
> > > It seems that for now the top-level namespaces (well, next-to-top) are
> > > - clojure.core
> > > - clojure.data
> > > - clojure.java
> > > - clojure.tools
> >
> > > I would like to suggest a new one, clojure.control, for control
> structures.
> > > This would be the natural home for monads, but also for parallelization
> > > frameworks and even for threading macros. None of this really fits into
> > > "data" or "tools".
> >
> > > If the goal is to keep the number of top-level namespaces as small as
> > > possible, I'd even propose to put clojure.contrib.generic under that
> label.
> > > Otherwise, I'd propose yet another namespace, clojure.interfaces, where
> the
> > > various submodules of generic would find their home next to other
> protocols
> > > and interfaces of general interest.
> >
> > > Konrad.
> >
> > > --
> > > 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
>

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

Emacs 23 issues.

2011-04-21 Thread mmwaikar
I am facing problem in using Emacs with Clojure. I am able to use it
with Lisp without any problems.

The problem is - I start the server using "lein swank" (from my
project dir) and then I start Emacs using "M-x slime-connect" but then
as soon as I start typing something in Emacs I get the error -

"lisp connection closed unexpectedly: connection broken by remote
peer"

and below is the java exception -

"unreadable message: (:emacs-rex (swank:autodoc (quote ("d" swank::
%cursor-marker%)) :print-right-margin 132) "user" :repl-thread 4)
exception in read loop
java.lang.RuntimeException: java.lang.Exception: Invalid token:
swank::"

Below is my .emacs file -

;; newer settings
(add-to-list 'load-path "~/.emacs.d/")
(require 'package)
(add-to-list 'package-archives
 '("marmalade" . "http://marmalade-repo.org/packages/";))

;; enter key should work as newline and indent
(add-hook 'lisp-mode-hook '(lambda ()
  (local-set-key (kbd "RET") 'newline-and-indent)))

;; set up the Common Lisp environment
(add-to-list 'load-path "/usr/share/common-lisp/source/slime/")

(require 'slime)
(slime-setup)

;; setting up the color-theme
(add-to-list 'load-path "/usr/share/emacs/site-lisp/emacs-goodies-el/
color-theme.el")
(require 'color-theme)
(eval-after-load "color-theme"
  '(progn
 (color-theme-initialize)
 (color-theme-hober)))

;; enable pasting to clipboard (from emacs)
(setq x-select-enable-clipboard t)

;; set the align-let utility
(add-to-list 'load-path "~/.emacs.d/elpa/align-cljlet")
(require 'align-cljlet)

;;; This was installed by package-install.el.
;;; This provides support for the package system and
;;; interfacing with ELPA, the package archive.
;;; Move this code earlier if you want to reference
;;; packages in your .emacs.
(when
(load
 (expand-file-name "~/.emacs.d/elpa/package.el"))
  (package-initialize))

I have the following installed -
clojure-mode 1.8.1
clojure-test-mode 1.5.5
durendal 0.1
magit 1.0.0
slime 20100404.1
slime-repl 20100404

Please let me know where is the problem. I am too frustrated with
these initial issues.

Thx and regards,
Manoj.


-- 
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: Why I'm getting an empty result?

2011-04-21 Thread Bhinderwala, Shoeb
Your function objects-at is correct but you have mixed up keywords and
strings in the definitions. Try the following:

(def *objects* '(:bottle :bucket :frog :chain))

(def *object-locations* {:bottle 'living-room, :bucket 'living-room,
:chain 'garden, :frog 'garden})

(defn objects-at [loc objs obj-locs]
  (letfn [(is-obj-at? [obj]
(= (obj obj-locs) loc))]
  (filter is-obj-at? objs)))

(println (objects-at 'garden *objects* *object-locations*)

-Original Message-
From: clojure@googlegroups.com [mailto:clojure@googlegroups.com] On
Behalf Of HB
Sent: Sunday, March 27, 2011 10:03 PM
To: Clojure
Subject: Why I'm getting an empty result?

Hi,
Would you please have a look at this code:


(def *objects* '(bottle bucket frog chain))

(def *object-locations* {:bottle 'living-room, :bucket 'living-
room, :chain 'garden, :frog 'garden})

(defn objects-at [loc objs obj-locs]
  (letfn [(is-obj-at? [obj]
(= (obj obj-locs) loc))]
  (filter is-obj-at? objs)))

(println (objects-at :garden *objects* *object-locations*))

Why the result is empty? Shouldn't it be (bottle bucket)?

Thanks for help and 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

-- 
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: Sharing a frustrating bug: using an atom to a hash as a hash

2011-04-21 Thread Armando Blancas
A type hint makes no difference because the param "state" is treated
as an Object instance.
user=> (:x @*aa*)
3
user=> (.invoke :x @*aa*) ; [16] invoke : Object (Object)
3

Besides, I don't think it's a good idea trying to setup some sort of
static type-checker and strongly-typed functions. You're bound to
shoot yourself somewhere else.

On Apr 21, 12:39 am, Albert Cardona  wrote:
> 2011/4/21 Tzach :
>
>
>
>
>
> > I made a stupid mistake, and I want to share. This is not the actual code, I
> > simplify it to demonstrate the point.
>
> > I use a atom to a global hash as follow:
>
> >  (def *aa* (atom {:x 3 :y 4 :z 17}))
>
> > Somewhere on the code, I have a function which look at the state and do
> > something:
>
> > (defn foo [state]
>
> >    (when (:x state) print "yes"))
>
> > My mistake - call foo as:
>
> > (foo *aa*)
>
> > where I should have call it
>
> > (foo @*aa*)
>
> > Since (:x (atom *aa*)) is nil, print was not execute.
>
> > 4 long hours later, I got it, fix it, and added the appropriate
> > precondition.
>
> > I understand there is no escape from my own silliness, but could I have
> > avoided this mistake to begin with?
>
> > Any best practice I broke?
>
> The compiler could have pointed out the error if you had given a type
> to the argument such as ^Map.
>
> (That is my main use for types: to prevent shooting myself on the foot
> like you did.)
>
> Albert
>
> --http://albert.rierol.net- Hide quoted text -
>
> - Show quoted text -

-- 
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: Future of clojure.contrib.core/-?> macro

2011-04-21 Thread pmbauer
Ivan,
clojure/core use a different workflow than is typical for github
projects.
The github readme doesn't indicate, but you may find the process here:

http://clojure.org/contributing
http://clojure.org/patches

Cheers,
pm

On Apr 20, 1:44 am, Ivan Koblik  wrote:
> Hello Konrad,
>
> Git workflow is a little bit different. You don't really need commit rights
> to contribute. I found a rather nice explanation of Git workflow 
> here:http://www.eqqon.com/index.php/Collaborative_Github_Workflow
>
> Hope it helps.
>
> Cheers,
> Ivan.
>
> On 19 April 2011 16:40, Konrad Hinsen  wrote:
>
>
>
> > On 19 Apr, 2011, at 13:56 , Stuart Halloway wrote:
>
> > >> Concerning my own modules in old contrib, there are three that I use
> > myself and that I am planning to maintain, independently of where they will
> > end up:
> > >> - clojure.contrib.monads
> > >> - clojure.contrib.macro-utils
> > >> - clojure.contrib.generic
>
> > > There is an empty repos already waiting for your macro utils:
> >https://github.com/clojure/tools.macro
>
> > Great, thanks, I'll start with that one. Monads depend on it anyway. But I
> > need commit permissions, which I probably don't have, but I don't even know
> > how to find out without trying to do a commit. Can you please add me in the
> > right place? My github account is khinsen.
>
> > > I have put some suggested names for the other new projects at
> >http://dev.clojure.org/display/design/Contrib+Library+Names. Please review
> > and comment, either there or here on the list.
>
> > It seems that for now the top-level namespaces (well, next-to-top) are
> > - clojure.core
> > - clojure.data
> > - clojure.java
> > - clojure.tools
>
> > I would like to suggest a new one, clojure.control, for control structures.
> > This would be the natural home for monads, but also for parallelization
> > frameworks and even for threading macros. None of this really fits into
> > "data" or "tools".
>
> > If the goal is to keep the number of top-level namespaces as small as
> > possible, I'd even propose to put clojure.contrib.generic under that label.
> > Otherwise, I'd propose yet another namespace, clojure.interfaces, where the
> > various submodules of generic would find their home next to other protocols
> > and interfaces of general interest.
>
> > Konrad.
>
> > --
> > 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: Future of clojure.contrib.core/-?> macro

2011-04-21 Thread pmbauer
clojure/core use an alternative workflow to typical OSS on github, so
the eqqon link is not apropos.
The clojure github readme doesn't advertise the workflow, but you can
find it here:

http://clojure.org/contributing
http://clojure.org/patches

On Apr 20, 1:44 am, Ivan Koblik  wrote:
> Hello Konrad,
>
> Git workflow is a little bit different. You don't really need commit rights
> to contribute. I found a rather nice explanation of Git workflow 
> here:http://www.eqqon.com/index.php/Collaborative_Github_Workflow
>
> Hope it helps.
>
> Cheers,
> Ivan.
>
> On 19 April 2011 16:40, Konrad Hinsen  wrote:
>
>
>
> > On 19 Apr, 2011, at 13:56 , Stuart Halloway wrote:
>
> > >> Concerning my own modules in old contrib, there are three that I use
> > myself and that I am planning to maintain, independently of where they will
> > end up:
> > >> - clojure.contrib.monads
> > >> - clojure.contrib.macro-utils
> > >> - clojure.contrib.generic
>
> > > There is an empty repos already waiting for your macro utils:
> >https://github.com/clojure/tools.macro
>
> > Great, thanks, I'll start with that one. Monads depend on it anyway. But I
> > need commit permissions, which I probably don't have, but I don't even know
> > how to find out without trying to do a commit. Can you please add me in the
> > right place? My github account is khinsen.
>
> > > I have put some suggested names for the other new projects at
> >http://dev.clojure.org/display/design/Contrib+Library+Names. Please review
> > and comment, either there or here on the list.
>
> > It seems that for now the top-level namespaces (well, next-to-top) are
> > - clojure.core
> > - clojure.data
> > - clojure.java
> > - clojure.tools
>
> > I would like to suggest a new one, clojure.control, for control structures.
> > This would be the natural home for monads, but also for parallelization
> > frameworks and even for threading macros. None of this really fits into
> > "data" or "tools".
>
> > If the goal is to keep the number of top-level namespaces as small as
> > possible, I'd even propose to put clojure.contrib.generic under that label.
> > Otherwise, I'd propose yet another namespace, clojure.interfaces, where the
> > various submodules of generic would find their home next to other protocols
> > and interfaces of general interest.
>
> > Konrad.
>
> > --
> > 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: Meta

2011-04-21 Thread Nick Zbinden
>What are meta data used for?
Its a open system it can be used for anything. If you have data about
your data that does not effect equality.

Examples:

The docstrings you can write in clojure are metadata.

(defn my-func
  "my-func does XY"
  [] "whatever")

This will be expanded to metadata like this: {:doc "my-func does XY"}
--
The same goes for test.

The are metadata on functions: {:test (fn .)}
--
An example that is used goes like this: if your mining data from the
net and other places you could that onto the data where you got it.

Example:

{:info "this is a good info"} could have the metadata {:source
www.whatever.com}
--

You could build a backup system where you tag your data with a
timestamp of the last backup.

--

>Are they similar to the reflective API in Java?
No, but you can use those from clojure too.

If you have to compair it to something in java I would say its
somewhat like annotations.
--

>Are they related to any FP theory?

No, not that I know of.

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


Meta

2011-04-21 Thread MohanR
I am just trying to understand the meta data support.

What are meta data used for ?

Are they similar to the reflective API in Java ?

Are they related to any FP theory ?

-- 
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: Future of clojure.contrib.core/-?> macro

2011-04-21 Thread Konrad Hinsen

On 20 Apr 2011, at 13:58, Stuart Halloway wrote:

There are several new top-level projects at https://github.com/ 
clojure to cover the various contrib libraries people have asked for.


Thanks!

I just pushed tools.macro to github. I'll wait a while to see if this  
causes any catastrophes. If not I'll go on with algo.monads and  
algo.generic.


Konrad.

--
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: Sharing a frustrating bug: using an atom to a hash as a hash

2011-04-21 Thread Albert Cardona
2011/4/21 Tzach :
> I made a stupid mistake, and I want to share. This is not the actual code, I
> simplify it to demonstrate the point.
>
> I use a atom to a global hash as follow:
>
>  (def *aa* (atom {:x 3 :y 4 :z 17}))
>
> Somewhere on the code, I have a function which look at the state and do
> something:
>
> (defn foo [state]
>
>    (when (:x state) print "yes"))
>
>
>
> My mistake - call foo as:
>
> (foo *aa*)
>
> where I should have call it
>
> (foo @*aa*)
>
>
>
> Since (:x (atom *aa*)) is nil, print was not execute.
>
> 4 long hours later, I got it, fix it, and added the appropriate
> precondition.
>
> I understand there is no escape from my own silliness, but could I have
> avoided this mistake to begin with?
>
> Any best practice I broke?


The compiler could have pointed out the error if you had given a type
to the argument such as ^Map.

(That is my main use for types: to prevent shooting myself on the foot
like you did.)

Albert

-- 
http://albert.rierol.net

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