Re: Nested identities in a value-based universe

2011-10-24 Thread Mike Anderson
On Oct 21, 9:04 pm, Meikel Brandmeyer (kotarak) m...@kotka.de
wrote:
 Hi,

 may I question the transitivity of state information?

 Maybe the world's state is that player Trantor is at position [15 34]. Now
 Trantor eats an appel. The appel is removed from his inventory and his
 health is raised by 5 hit points. Did the state of the world change? No.
 Trantor is still at position [15 34]. Does the world have to know about the
 apple in Trantors inventory and the sad state of his hit points?

 Disclaimer: I have no clue about game programming, about what information is
 needed where and how this is implemented insanely fast. Just a naive
 question from the distance.

I think it generally makes sense to consider the entire world
including Trantor and his tasty apple as part of the world state. This
seems logically consistent - they are part of the world and it would
seem odd if some actions like dropping an apple on the ground at [15
34] altered the world state but eating an apple didn't.

It also has nice properties. you can then treat the world state as
a single value that you can pass to functions etc.

e.g. you could create a higher order functions to update the world
with something like:

  ((command Trantor :eat apple) world-state)

The problem with identities of actors comes in when you consider code
like the following:

  (def trantor (get-actor Trantor world-state))

  (:hit-points trantor)
  = 10

  (def new-world-state ((command Trantor :eat apple) world-state))

  (:hit-points trantor)
  = 10 (still!! because we took a snapshot of trantor..)

  (def new-trantor (get-actor Trantor new-world-state))

  (:hit-points new-trantor)
  = 15

Maybe this is all fine and I'm sure it is possible to successfully
write a game this way. However it does feel a little strange when you
are coming from OOP languages where you are used to simulating
everything with mutable state

-- 
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: Nested identities in a value-based universe

2011-10-24 Thread Ulises
 The problem with identities of actors comes in when you consider code
 like the following:

  (def trantor (get-actor Trantor world-state))

  (:hit-points trantor)
  = 10

  (def new-world-state ((command Trantor :eat apple) world-state))

  (:hit-points trantor)
  = 10     (still!! because we took a snapshot of trantor..)

  (def new-trantor (get-actor Trantor new-world-state))

  (:hit-points new-trantor)
  = 15

 Maybe this is all fine and I'm sure it is possible to successfully
 write a game this way. However it does feel a little strange when you
 are coming from OOP languages where you are used to simulating
 everything with mutable state

I think that's the issue. Expecting your def-ed trantor to change once
the world state has been updated is what would be expected in a world
of pointers, OOP, etc. However, the new updated world (in my view) has
a new trantor which you need to extract with your (get-actor ...).

This would all seem reasonable to me (modulo performance of updating
the world, etc.) since then you have many functions operating on a
single data structure and your flow is in terms of these functions
only.

Cheers,

U

-- 
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 1.3 treatment of integers and longs

2011-10-24 Thread Rich Hickey
How can people toggle between the various commits I mentioned using Maven?

Rich

On Oct 23, 2011, at 9:52 PM, Stuart Sierra wrote:

 As a reminder, you don't need Git to use the latest development version of 
 Clojure. Just set your Clojure dependency version to 1.4.0-master-SNAPSHOT 
 and add Sonatype to your Maven repositories.
 
 Detailed instructions here: 
 http://dev.clojure.org/display/doc/Maven+Settings+and+Repositories
 
 -Stuart Sierra
 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: clojure starter package for aichallenge ?

2011-10-24 Thread faenvie
hmm ... last time i visited the starter_packages-page
the link to clojure was inactive.

howsoever ... i apologise. thanks for implementing this.

no clojure-program in top chart so far ... ;-)


On Oct 22, 8:46 am, Chris Granger ibdk...@gmail.com wrote:
 Hm? My starter package is there:

 http://aichallenge.org/starter_packages.php

 They changed the game at the end and I didn't have time to update it
 for hills, but it actually works just fine as is. Also, it should be
 fairly trivial for someone to add that bit...

 Cheers,
 Chris.

 On Oct 20, 11:58 am, faenvie fanny.aen...@gmx.de wrote:

  hi clojure community,

  at the moment there seems to be no applicable
  clojure starter package for thehttp://aichallenge.org/

  though some work has be done on it by chris granger, i
  think:https://github.com/ibdknox/aichallenge

  are there any plans to get a clojure starter package out ?
  it would be nice to see clojure-programs participate in the
  challenge.

  have a successful day

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


Can Simple be done with Static Typing?

2011-10-24 Thread Timothy Baldridge
After watching Rich's talk the other day about Making Simple Easy, I
started thinking about how to incorporate parts of this talk into the
software we're writing at work. During this thought process, I have
begun to wonder, are simple and statically typed languages mutually
exclusive?

Let me explain by a simple example. In the following text, I will be
using C# as my example static language, and Clojure as my example
dynamic language.

For instance, let's say we have two structures, Contact and Staff. The
two are completely unrelated, except for the fact that they both have
a first name, and they both are required fields:

Clojure:

{:first-name Billy :age 42 :record-type Contact}
{:first-name Joe :position manager  :record-type Staff}

Now in Clojure, writing a validation check for this is as simple as:

(not (nil? (:first-name record)))

But how would we do this in C#?

new Person() {firstName=Billy, age=42 };
new Contact() {firstName Joe, Position=manager};

Person and Contact are unrelated, so I'm left with duplicating my
validation routines (once for each object), or going and making both
implement IFirstName. This gets even more fun when you start taking
into account generics: In C# a ListIFirstName cannot be casted to a
ListPerson because they are considered two completely different
objects.

In the Clojure source code, Rich gets around most of the above issues
by simply referring to everything as a object and then casting to get
the type at runtime. This works fine for code that will be run in a
dynamic language anyways, but makes for some ugly code when you're
actually writing the static language parts:

if (lst[0] is IFirstName) runFirstNameChecks(lst[0]);
if (lst[0] is Person) runPersonChecks(lst[0]);

However, this then requires tons of type checks and casting throughout
the entire system.

So yes, I understand that this is all a bit off-topic for a Clojure
mailing list, but I thought it was applicable to Rich's talk. Are we
getting half way to simple, simply by using Clojure in the first
place? Is it possible to write simple code in a language that shuns
the use of simple containers (List, Dictionary, etc.) as the primary
transport system for data?

If anyone has some thoughts, they are more than welcome to ponder them
out-loud with me on this thread

Timothy

-- 
“One of the main causes of the fall of the Roman Empire was
that–lacking zero–they had no way to indicate successful termination
of their C programs.”
(Robert Firth)

-- 
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 1.3 wonky behavior

2011-10-24 Thread Micah Martin
Thanks for the explanation All.  I have a much better grasp of what's going on 
now. 

Just one more question: It is defined behavior, or should I submit a patch for 
Clojure 1.3?

Micah

On Oct 20, 2011, at 7:55 PM, Chouser wrote:

 On Thu, Oct 20, 2011 at 4:31 PM, Chris Perkins chrisperkin...@gmail.com 
 wrote:
 Note: I forgot to preface that with I think... :)  Upon experimenting
 briefly, it turns out I was wrong about how Clojure works (that seems to
 happen a lot with me).  A declare/def defines a var even when it's not
 executed!
 user (defn xxx [] (declare yyy))
 #'user/xxx
 user yyy
 #Unbound Unbound: #'user/yyy
 Well, I learned something today.
 
 But it only interns the Var, it doesn't fully set it up.  Particularly
 relevant to the OP's example is that the metadata from the name symbol
 is not transferred to the Var (and the changes to the Var based on
 :dynamic are not applied) until runtime for the 'def', even though the
 Var exists at compile time.
 
 Here's a macro that expands at compile time to the *compile* time
 metadata of the var named in its argument:
 
 (defmacro compile-time-meta [x] (meta (resolve x)))
 
 Now observe how it behaves differently than a runtime call to 'meta':
 
 (vector
  (declare ^:dynamic *myvar*)
  (meta #'*myvar*)
  (compile-time-meta #'*myvar*)))
 
 The above returns:
 
 [#'user/*myvar*
 {:ns #Namespace user, :name *myvar*, :dynamic true, :declared true, ...}
 {:ns #Namespace user, :name #Unbound Unbound: #'user/*myvar*}]
 
 First is the Var itself.
 Next is the metadata of the Var at runtime, after the entire form has
 been compiled and therefore the metadata from the name has been
 applied to the Var, including the :dynamic flag.
 Finally we see that when our macro was expanded the Var existed but
 had minimal metadata.  This was after the declare was compiled but
 before any part of the 'vector' form was run.  There is no :dynamic
 flag, and anything that depends on that flag at compile time to work
 correctly (such as a function that refers the for Var) will fail to
 work correctly.
 
 --Chouser
 
 -- 
 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: Can Simple be done with Static Typing?

2011-10-24 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

i have some (10 years) experience with difference statically typed
languages and a bit with dynamic ones. i encountered a few typesafe
solutions that don't introduce a lot of overhead - for example the
types of scala. in addition to interfaces and classes, scala has
types. a type can be an arbitrary set of field and method definitions,
for example:
type foo = {
   def x:String
   val y:Int
}

every instance that has a method x which returns a string and a field
which is an int are compatible to foo. in java, you would say it is a
delayed interface. the code behaves as if someone magically attached
implements foo to any class which would still compile.

so your (not (nil? (:first-name record))) would work in scala if
there was a type like type bar = {
   val firstName:String
}

it's implemented via reflection, but the types are checked at compile
time.



Am 24.10.2011 15:28, schrieb Timothy Baldridge:
 After watching Rich's talk the other day about Making Simple
 Easy, I started thinking about how to incorporate parts of this
 talk into the software we're writing at work. During this thought
 process, I have begun to wonder, are simple and statically typed
 languages mutually exclusive?
 
 Let me explain by a simple example. In the following text, I will
 be using C# as my example static language, and Clojure as my
 example dynamic language.
 
 For instance, let's say we have two structures, Contact and Staff.
 The two are completely unrelated, except for the fact that they
 both have a first name, and they both are required fields:
 
 Clojure:
 
 {:first-name Billy :age 42 :record-type Contact} {:first-name
 Joe :position manager  :record-type Staff}
 
 Now in Clojure, writing a validation check for this is as simple
 as:
 
 (not (nil? (:first-name record)))
 
 But how would we do this in C#?
 
 new Person() {firstName=Billy, age=42 }; new Contact() {firstName
 Joe, Position=manager};
 
 Person and Contact are unrelated, so I'm left with duplicating my 
 validation routines (once for each object), or going and making
 both implement IFirstName. This gets even more fun when you start
 taking into account generics: In C# a ListIFirstName cannot be
 casted to a ListPerson because they are considered two completely
 different objects.
 
 In the Clojure source code, Rich gets around most of the above
 issues by simply referring to everything as a object and then
 casting to get the type at runtime. This works fine for code that
 will be run in a dynamic language anyways, but makes for some ugly
 code when you're actually writing the static language parts:
 
 if (lst[0] is IFirstName) runFirstNameChecks(lst[0]); if (lst[0] is
 Person) runPersonChecks(lst[0]);
 
 However, this then requires tons of type checks and casting
 throughout the entire system.
 
 So yes, I understand that this is all a bit off-topic for a
 Clojure mailing list, but I thought it was applicable to Rich's
 talk. Are we getting half way to simple, simply by using Clojure in
 the first place? Is it possible to write simple code in a language
 that shuns the use of simple containers (List, Dictionary, etc.) as
 the primary transport system for data?
 
 If anyone has some thoughts, they are more than welcome to ponder
 them out-loud with me on this thread
 
 Timothy
 


- -- 

-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.14 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOpZetAAoJENRtux+h35aGhTsP+wUYHLD0i8t4DI7P/d2A13Ca
29hIhICsxJ2IE3svctaobozaT1byzzpYq6NFfqcfdwfOJCAJBCxmrHTiTCQ09EPM
jSZpxiXQSXHtYDpn2AiYA5c5Ut+TXjbWeahKjyRGrUVKjORtPHvaWGccj0b5vzYT
m7QpMy7R0tzEj/w2FCIkWkjqvJeCQ3cYNC78GZ2gIHC9DQwAjeD2uKSX3RfwaD3S
apEJELCYeDS08NIS26uB0ZHbo228rLlr02WaXh/+rx/MlMlEE/MEIq0aqJV59J7J
A6EFqoC43LxpftJRfAJ3MHRoliC0mnGN9SoWKeRiE0i8p1g8pv1e74DpLzI/I/Pq
GeR9TL688wyhnehl8VZW9AEKQVfKOujPIkKdpr4eF98eKdxHdu4xwkKi/ZgL6zCf
h7/eO6QRrKsOLfztMNQsaYqpCP/pFGA2J3p4Q/oVkB2Uqa6xa0auNcY5mBSPNuZp
zKcOg6/gi39eOZxFslVOvnY6ZOcILjRJYoA1VcO834NMd0A+D6lP0UM0ReBb28kg
MLjhDstZC1xVShp9PVJAdMlMeNjRDOPcASQG6uCisTSGfQ7qVXBNYd/SqXyRUODn
YFTSYtncEu+Pq0nRIjl1ItBmP/9saEqqJwiOpW01IAT+mFVv10tqKCxWFJKwNcLQ
iolsrCZa8Yn9Tvt2hFEL
=UbSd
-END PGP SIGNATURE-

-- 
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: Rich Hickey: Simple Made Easy from Strange Loop 2011

2011-10-24 Thread Sean Corfield
On Fri, Oct 21, 2011 at 10:05 AM, Michael Forster m...@sharedlogic.ca wrote:
 Yes:  Was that a nil value for the key :foo in my map or did :foo not
 exist?

If you need to distinguish between :foo is missing and :foo's value
indicates non-existence, what about:

(get my-map :foo ::missing)
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.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: Rich Hickey: Simple Made Easy from Strange Loop 2011

2011-10-24 Thread Ambrose Bonnaire-Sergeant
Or:

(if-let [[_ v] (find my-map key)]
   v
   :something-else)

On Tue, Oct 25, 2011 at 1:19 AM, Sean Corfield seancorfi...@gmail.comwrote:

 On Fri, Oct 21, 2011 at 10:05 AM, Michael Forster m...@sharedlogic.ca
 wrote:
  Yes:  Was that a nil value for the key :foo in my map or did :foo not
  exist?

 If you need to distinguish between :foo is missing and :foo's value
 indicates non-existence, what about:

 (get my-map :foo ::missing)
 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View -- http://corfield.org/
 World Singles, LLC. -- http://worldsingles.com/
 Railo Technologies, Inc. -- http://www.getrailo.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: Clojure 1.3 treatment of integers and longs

2011-10-24 Thread Kevin Downey
;; lein for all 3 commits
[org.clojure/clojure 1.4.0-master-20111023.210239-5]

and I imagine you can do something similar with maven, the main thing
is you need to add the sonatype snapshot repo.

but you can't access individual commits because the build machine
polls and gathers the latest commits together and does a build.

and the readme.txt has build instructions for ant and maven for those
who don't know how to build clojure from git.

On Mon, Oct 24, 2011 at 4:04 AM, Rich Hickey richhic...@gmail.com wrote:
 How can people toggle between the various commits I mentioned using Maven?

 Rich

 On Oct 23, 2011, at 9:52 PM, Stuart Sierra wrote:

 As a reminder, you don't need Git to use the latest development version of 
 Clojure. Just set your Clojure dependency version to 1.4.0-master-SNAPSHOT 
 and add Sonatype to your Maven repositories.

 Detailed instructions here: 
 http://dev.clojure.org/display/doc/Maven+Settings+and+Repositories

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



-- 
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?

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


Confusing interplay between macros and metadata

2011-10-24 Thread Alan Malloy
I'm struggling with a basic feature of how macros behave. I understand
how the
problem arises, and I can cobble together my own fix in the specific
places
where it's causing me trouble, but it seems like a prettier, more
general
solution would be desirable. Below is a brief transcript demonstrating
the
problem.

user (defmacro call [f arg] `(~f ~arg))
#'user/call
user (let [f inc] (.intValue (f 10)))
Reflection warning, NO_SOURCE_FILE:1 - reference to field intValue
can't be resolved.
11
user (let [f inc] (.intValue ^Integer (f 10)))
11
user (let [f inc] (.intValue ^Integer (call f 10)))
Reflection warning, NO_SOURCE_FILE:1 - reference to field intValue
can't be resolved.
11

I want to typehint the return value of f, so I put metadata on the
form
representing a call to it. But if a macro gets involved, there's an
intervening form that ignores its metadata and returns a new list of
'(f 10)
with no metadata. Thus the compiler has no idea I ever wanted to give
it a hint
about the type.

There are two solutions that are simple enough for me to apply:

(1) At the call site I can bind the result of (call f 10) to a local
named i and
then put the typehinting metadata on that

(2) I can edit the call macro to return a form with the right
metadata:
(defmacro call [f arg] (with-meta `(~f ~arg) (meta form)))

Both of these work, but they seem awful. If the language specifies
you're
supposed to be able to typehint expressions as well as named bindings,
it's both
unintuitive and quite inconvenient that most macros do not respect
this
behavior by default. And many macros I don't have enough control over
to make
this change. For example, the whole issue arose when I was trying to
hint the
result of a (for ...) as a java.util.List. It ignores my metadata and
returns a
new form; and I certainly can't go edit its source, so instead I have
to bind
the result in a let, for no reason other than to typehint it.

It seems to me that it would be nice to have macros automatically
include, on
their result forms, the metadata from their input form. Of course,
macros may
wish to add metadata as well, so the two maps should probably be
merged. However, there are certainly some problems with this approach:
for
example if a macro wants to return something that can't suppport
metadata (like
an Integer), the compiler needs to be careful not to try to include
it. So I'm
hoping the community can comment on whether this feature would be
useful, or
whether there are fundamental problems with it that I haven't
foreseen. Is there
a reason this can't make it into a future version of Clojure?

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


Quick Practical Clojure macro question

2011-10-24 Thread Alan O'Donnell
Hi everyone,

I'm working my way through Practical Clojure's macro chapter, and I'd like 
to check my understanding about one of the examples.

The book discusses writing a macro to randomly evaluate a form out of a list 
of forms--essentially a cond that randomly selects which branch to evaluate.

The book's version looks like this:

(defmacro rand-expr-multi [ exprs] 

  `(let [ct# ~(count exprs)]

(case (rand-int ct#) 

  ~@(interleave (range (count exprs)) exprs

My version looks like this:

(defmacro rand-expr-mulit [ exprs]

  (let [n (rand-int (count exprs))]

(nth exprs n)))

Is there any difference between the two? I'm a little shaky on macro 
expansion-time vs run-time, hygiene, etc.

-- 
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: Quick Practical Clojure macro question

2011-10-24 Thread Alan Malloy
Yes, definitely. Your version selects which form to evaluated once, at
compile time; the original selects a form every time the expansion is
evaluated.

user (defn rand-num [] (rand-expr-mulit 1 2 3 4 5 6 7 8 9))
#'user/rand-num
user (rand-num)
7
user (rand-num)
7
user (rand-num)
7
user (rand-num)
7

Instead, you need to make sure the call to rand-int is in the code you
return, rather than in the logic the macro uses to decide what code to
return.

On Oct 24, 12:17 pm, Alan O'Donnell alan.m.odonn...@gmail.com wrote:
 Hi everyone,

 I'm working my way through Practical Clojure's macro chapter, and I'd like
 to check my understanding about one of the examples.

 The book discusses writing a macro to randomly evaluate a form out of a list
 of forms--essentially a cond that randomly selects which branch to evaluate.

 The book's version looks like this:

 (defmacro rand-expr-multi [ exprs]

   `(let [ct# ~(count exprs)]

     (case (rand-int ct#)

       ~@(interleave (range (count exprs)) exprs

 My version looks like this:

 (defmacro rand-expr-mulit [ exprs]

   (let [n (rand-int (count exprs))]

     (nth exprs n)))

 Is there any difference between the two? I'm a little shaky on macro
 expansion-time vs run-time, hygiene, etc.

-- 
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: Confusing interplay between macros and metadata

2011-10-24 Thread Kevin Downey
it's not a macro issue, it's a syntax quote issue

On Mon, Oct 24, 2011 at 11:54 AM, Alan Malloy a...@malloys.org wrote:
 I'm struggling with a basic feature of how macros behave. I understand
 how the
 problem arises, and I can cobble together my own fix in the specific
 places
 where it's causing me trouble, but it seems like a prettier, more
 general
 solution would be desirable. Below is a brief transcript demonstrating
 the
 problem.

 user (defmacro call [f arg] `(~f ~arg))
 #'user/call
 user (let [f inc] (.intValue (f 10)))
 Reflection warning, NO_SOURCE_FILE:1 - reference to field intValue
 can't be resolved.
 11
 user (let [f inc] (.intValue ^Integer (f 10)))
 11
 user (let [f inc] (.intValue ^Integer (call f 10)))
 Reflection warning, NO_SOURCE_FILE:1 - reference to field intValue
 can't be resolved.
 11

 I want to typehint the return value of f, so I put metadata on the
 form
 representing a call to it. But if a macro gets involved, there's an
 intervening form that ignores its metadata and returns a new list of
 '(f 10)
 with no metadata. Thus the compiler has no idea I ever wanted to give
 it a hint
 about the type.

 There are two solutions that are simple enough for me to apply:

 (1) At the call site I can bind the result of (call f 10) to a local
 named i and
 then put the typehinting metadata on that

 (2) I can edit the call macro to return a form with the right
 metadata:
 (defmacro call [f arg] (with-meta `(~f ~arg) (meta form)))

 Both of these work, but they seem awful. If the language specifies
 you're
 supposed to be able to typehint expressions as well as named bindings,
 it's both
 unintuitive and quite inconvenient that most macros do not respect
 this
 behavior by default. And many macros I don't have enough control over
 to make
 this change. For example, the whole issue arose when I was trying to
 hint the
 result of a (for ...) as a java.util.List. It ignores my metadata and
 returns a
 new form; and I certainly can't go edit its source, so instead I have
 to bind
 the result in a let, for no reason other than to typehint it.

 It seems to me that it would be nice to have macros automatically
 include, on
 their result forms, the metadata from their input form. Of course,
 macros may
 wish to add metadata as well, so the two maps should probably be
 merged. However, there are certainly some problems with this approach:
 for
 example if a macro wants to return something that can't suppport
 metadata (like
 an Integer), the compiler needs to be careful not to try to include
 it. So I'm
 hoping the community can comment on whether this feature would be
 useful, or
 whether there are fundamental problems with it that I haven't
 foreseen. Is there
 a reason this can't make it into a future version of Clojure?

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




-- 
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?

-- 
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: Can Simple be done with Static Typing?

2011-10-24 Thread ngocdaothanh
More about Scala:
http://www.slideshare.net/El_Picador/scala-vs-ruby

-- 
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: trouble setting up emacs

2011-10-24 Thread Howard Lewis Ship
I've gotten as far as changing to a directory with a project.clj and
execute C-c C-j C-i

I see this in my *swank* buffer:


Process swank exited abnormally with code 127
sh: line 1: lein: command not found


lein is on my search path (in ~/bin).  Where do I update things so
that it is on the path for the Swank process?

On Tue, Oct 18, 2011 at 4:07 AM, MarisO maris.orbid...@gmail.com wrote:
 run this script in your .emacs.d directory

 --
 #!/bin/sh

 git clone https://github.com/technomancy/clojure-mode.git
 wget -P paredit http://mumble.net/~campbell/emacs/paredit.el

 wget 
 http://download.savannah.gnu.org/releases/color-theme/color-theme-6.6.0.tar.gz
 mkdir color-theme
 tar --strip-components=1 --directory=color-theme -xzf color-
 theme-6.6.0.tar.gz

 rm color-theme-6.6.0.tar.gz
 --


 init.el

 --
 (add-to-list 'load-path ~/.emacs.d/)

 ;; clojure-mode
 (add-to-list 'load-path ~/.emacs.d/clojure-mode)
 (require 'clojure-mode)

 (fset 'compile-and-goto-repl \C-x\C-s\C-c\C-k\C-c\C-z)

 (global-set-key (kbd C-c C-g C-r) 'compile-and-goto-repl)
 (global-set-key (kbd C-c C-j C-i) 'clojure-jack-in)

 ;; paredit
 (add-to-list 'load-path ~/.emacs.d/paredit)
 (require 'paredit)

 (add-hook 'clojure-mode-hook 'enable-paredit-mode)

 (global-set-key (kbd M-p M-m e) 'enable-paredit-mode)
 (global-set-key (kbd M-p M-m d) 'disable-paredit-mode)

 ;; color theme
 (add-to-list 'load-path ~/.emacs.d/color-theme)
 (require 'color-theme)

 (eval-after-load color-theme
  '(progn
     (color-theme-initialize)))

 --



 Start emacs, change current directory (M-x cd) to a leiningen project
 root and press C-c C-j C-i.    It should start clojure repl.
 You will need swank as dev dependency.

 :dev-dependencies [[swank-clojure 1.3.1]
                     [midje 1.1.1]]



 hth,
 Maris



 On Oct 18, 4:32 am, Bruce Gordon brucebgor...@gmail.com wrote:
 I am trying to follow the directions 
 athttp://dev.clojure.org/display/doc/Getting+Started+with+Emacs.
 1. I want to install the Emacs Starter Kit. The directions 
 athttp://dev.clojure.org/display/doc/Getting+Started+with+Emacsmention
 GNU Emacs 23 or 24 is recommended, however  
 https://github.com/technomancy/emacs-starter-kit
 says You'll need Emacs 24.  The directions say precompiled versions
 are readily available for Debian-based systems I'm using a Debian
 based system. so I went tohttp://emacs.naquadah.org/.
 a. I executed wget -q -O -http://emacs.naquadah.org/key.gpg| sudo
 apt-key add -
 b. I'm now confused as to which version I want: Stable? If so I should
 then follow the directions to add 2 lines to /etc/apt/sources.list,
 and then what do I do?

 2. Once I get emacs 24 installed, the directions sort of leave off
 with  In both cases, you need to launch a Clojure instance with the
 correct classpath settings. This is most commonly done using a build
 tool such as Leiningen. For instructions see the Build Tools section
 of Getting Started. Going 
 tohttp://dev.clojure.org/display/doc/Getting+Started
 and perusing the Build Tools doesn't explain how to setup and launch a
 Clojure instance. I see some explanations 
 athttp://blog.bensmann.com/setting-up-a-clojure-development-environment
 but don't know if that includes some obsolete directions.

 thanks, -Bruce

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



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.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: trouble setting up emacs

2011-10-24 Thread gaz jones
some kind soul gave me this on the mailing list a while ago, works for me:

;; fix the PATH variable
(defun set-exec-path-from-shell-PATH ()
  (let ((path-from-shell (shell-command-to-string $SHELL -i -c 'echo $PATH')))
(setenv PATH path-from-shell)
(setq exec-path (split-string path-from-shell path-separator

(if window-system (set-exec-path-from-shell-PATH))

shove that in your init.el or wherever you are putting your
customisations. it adds your shell path to emacs path and should
enable emacs to find lein.

On Mon, Oct 24, 2011 at 6:28 PM, Howard Lewis Ship hls...@gmail.com wrote:
 I've gotten as far as changing to a directory with a project.clj and
 execute C-c C-j C-i

 I see this in my *swank* buffer:


 Process swank exited abnormally with code 127
 sh: line 1: lein: command not found


 lein is on my search path (in ~/bin).  Where do I update things so
 that it is on the path for the Swank process?

 On Tue, Oct 18, 2011 at 4:07 AM, MarisO maris.orbid...@gmail.com wrote:
 run this script in your .emacs.d directory

 --
 #!/bin/sh

 git clone https://github.com/technomancy/clojure-mode.git
 wget -P paredit http://mumble.net/~campbell/emacs/paredit.el

 wget 
 http://download.savannah.gnu.org/releases/color-theme/color-theme-6.6.0.tar.gz
 mkdir color-theme
 tar --strip-components=1 --directory=color-theme -xzf color-
 theme-6.6.0.tar.gz

 rm color-theme-6.6.0.tar.gz
 --


 init.el

 --
 (add-to-list 'load-path ~/.emacs.d/)

 ;; clojure-mode
 (add-to-list 'load-path ~/.emacs.d/clojure-mode)
 (require 'clojure-mode)

 (fset 'compile-and-goto-repl \C-x\C-s\C-c\C-k\C-c\C-z)

 (global-set-key (kbd C-c C-g C-r) 'compile-and-goto-repl)
 (global-set-key (kbd C-c C-j C-i) 'clojure-jack-in)

 ;; paredit
 (add-to-list 'load-path ~/.emacs.d/paredit)
 (require 'paredit)

 (add-hook 'clojure-mode-hook 'enable-paredit-mode)

 (global-set-key (kbd M-p M-m e) 'enable-paredit-mode)
 (global-set-key (kbd M-p M-m d) 'disable-paredit-mode)

 ;; color theme
 (add-to-list 'load-path ~/.emacs.d/color-theme)
 (require 'color-theme)

 (eval-after-load color-theme
  '(progn
     (color-theme-initialize)))

 --



 Start emacs, change current directory (M-x cd) to a leiningen project
 root and press C-c C-j C-i.    It should start clojure repl.
 You will need swank as dev dependency.

 :dev-dependencies [[swank-clojure 1.3.1]
                     [midje 1.1.1]]



 hth,
 Maris



 On Oct 18, 4:32 am, Bruce Gordon brucebgor...@gmail.com wrote:
 I am trying to follow the directions 
 athttp://dev.clojure.org/display/doc/Getting+Started+with+Emacs.
 1. I want to install the Emacs Starter Kit. The directions 
 athttp://dev.clojure.org/display/doc/Getting+Started+with+Emacsmention
 GNU Emacs 23 or 24 is recommended, however  
 https://github.com/technomancy/emacs-starter-kit
 says You'll need Emacs 24.  The directions say precompiled versions
 are readily available for Debian-based systems I'm using a Debian
 based system. so I went tohttp://emacs.naquadah.org/.
 a. I executed wget -q -O -http://emacs.naquadah.org/key.gpg| sudo
 apt-key add -
 b. I'm now confused as to which version I want: Stable? If so I should
 then follow the directions to add 2 lines to /etc/apt/sources.list,
 and then what do I do?

 2. Once I get emacs 24 installed, the directions sort of leave off
 with  In both cases, you need to launch a Clojure instance with the
 correct classpath settings. This is most commonly done using a build
 tool such as Leiningen. For instructions see the Build Tools section
 of Getting Started. Going 
 tohttp://dev.clojure.org/display/doc/Getting+Started
 and perusing the Build Tools doesn't explain how to setup and launch a
 Clojure instance. I see some explanations 
 athttp://blog.bensmann.com/setting-up-a-clojure-development-environment
 but don't know if that includes some obsolete directions.

 thanks, -Bruce

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



 --
 Howard M. Lewis Ship

 Creator of Apache Tapestry

 The source for Tapestry training, mentoring and support. Contact me to
 learn how I can get you up and productive in Tapestry fast!

 (971) 678-5210
 http://howardlewisship.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.
 

Re: trouble setting up emacs

2011-10-24 Thread Phil Hagelberg
On Mon, Oct 24, 2011 at 4:28 PM, Howard Lewis Ship hls...@gmail.com wrote:
 lein is on my search path (in ~/bin).  Where do I update things so
 that it is on the path for the Swank process?

In Mac OS X, usually programs that are launched from the GUI don't get
their environment variables (like $PATH) set correctly. Supposedly
there's a fix, but it involves editing a file called plist.xml, so I
have a hard time recommending it with a clear conscience.

-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: trouble setting up emacs

2011-10-24 Thread Howard Lewis Ship
This was helpful:

http://www.emacswiki.org/emacs/MacOSTweaks#toc14

I added the following to my init.el:

(setenv PATH (concat (getenv PATH) :~/bin))
(setq exec-path (append exec-path `(~/bin)))


Seems like I could have used (add-to-list 'exec-path ~/bin) for the
second line, is that right?

In any case, my next step is to see if Swank is working (it would help
if I knew what Swank was supposed to do!)

On Mon, Oct 24, 2011 at 4:33 PM, Phil Hagelberg p...@hagelb.org wrote:
 On Mon, Oct 24, 2011 at 4:28 PM, Howard Lewis Ship hls...@gmail.com wrote:
 lein is on my search path (in ~/bin).  Where do I update things so
 that it is on the path for the Swank process?

 In Mac OS X, usually programs that are launched from the GUI don't get
 their environment variables (like $PATH) set correctly. Supposedly
 there's a fix, but it involves editing a file called plist.xml, so I
 have a hard time recommending it with a clear conscience.

 -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



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.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: trouble setting up emacs

2011-10-24 Thread Howard Lewis Ship
So Swank appears to be running, but when I edit a Clojure file and hit
C-x C-e I get an error:

Symbol's function definition is void: lisp-eval-last-sexp

I also see this in my *messages* buffer:

error in process filter: require: Symbol's value as variable is void: slime-clj

Any ideas ... even on where to start?



On Mon, Oct 24, 2011 at 4:55 PM, Howard Lewis Ship hls...@gmail.com wrote:
 This was helpful:

 http://www.emacswiki.org/emacs/MacOSTweaks#toc14

 I added the following to my init.el:

 (setenv PATH (concat (getenv PATH) :~/bin))
 (setq exec-path (append exec-path `(~/bin)))


 Seems like I could have used (add-to-list 'exec-path ~/bin) for the
 second line, is that right?

 In any case, my next step is to see if Swank is working (it would help
 if I knew what Swank was supposed to do!)

 On Mon, Oct 24, 2011 at 4:33 PM, Phil Hagelberg p...@hagelb.org wrote:
 On Mon, Oct 24, 2011 at 4:28 PM, Howard Lewis Ship hls...@gmail.com wrote:
 lein is on my search path (in ~/bin).  Where do I update things so
 that it is on the path for the Swank process?

 In Mac OS X, usually programs that are launched from the GUI don't get
 their environment variables (like $PATH) set correctly. Supposedly
 there's a fix, but it involves editing a file called plist.xml, so I
 have a hard time recommending it with a clear conscience.

 -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



 --
 Howard M. Lewis Ship

 Creator of Apache Tapestry

 The source for Tapestry training, mentoring and support. Contact me to
 learn how I can get you up and productive in Tapestry fast!

 (971) 678-5210
 http://howardlewisship.com




-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.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: Clojure 1.3 wonky behavior

2011-10-24 Thread Rich Hickey
You should use 'do' for that kind of thing, not list.

Rich

On Oct 20, 2011, at 1:53 PM, Micah Martin wrote:

 I recently tried to get Speclj running on Clojure 1.3 and came across the 
 following problem:
 
 (list
  (declare ^:dynamic p)
  (defn q [] @p))
 
 (binding [p (atom 10)]
  (q))
 
 java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to 
 clojure.lang.IDeref
 
 Thanks to @cemerick for helping me condense the snippet, and thanks to both 
 @cemerick and @chouser for the lively discussion on IRC.  Yet the discussion 
 was inconclusive.  Is the above expected behavior? 
 
 Micah
 
 -- 
 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: Nested identities in a value-based universe

2011-10-24 Thread Alasdair MacLeod
 I think that's the issue. Expecting your def-ed trantor to change once
 the world state has been updated is what would be expected in a world
 of pointers, OOP, etc. However, the new updated world (in my view) has
 a new trantor which you need to extract with your (get-actor ...).

 This would all seem reasonable to me (modulo performance of updating
 the world, etc.) since then you have many functions operating on a
 single data structure and your flow is in terms of these functions
 only.
Meta-physics aside, if you have a single threaded app then a single
lump of data is all you need.  Each epoch follows the last along the
single thread of execution, calculated at the CPU's leisure using the
input state.  If, on the other hand, you wish to run multiple threads,
that you need to deal with concurrent updates and this is when
Clojure's concurrency constructs come into play.  How you actually
partition the data behind refs or actors depends on the problem domain
and the structure of your data; the refs and actors etc define your
units of concurrent change.  For an example you could look at the ants
demo.

Alasdair

-- 
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: Bug in keyword handling?

2011-10-24 Thread Alasdair MacLeod
 this:  There may be situations, now or in the future, where it is desirable
 to create Keywords containing non-`read`able characters. Therefore, don't
 use Keywords for things that may contain non-`read`able characters if you
 want to print and read them.

 -Stuart Sierra
 clojure.com
Stuart, so it's a known quirk - thanks for this.

Alasdair

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


Get key from map

2011-10-24 Thread pistacchio
Hi! Since both (:a {:a 1 :b 2}) and ({:a 1 :b 2} :a) return the
correct value, is there any difference between the two? What is the
preferred form?

Thanks.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojure 1.3 treatment of integers and longs

2011-10-24 Thread Stuart Sierra
You can't jump around at a per-commit level (unless there's one build for 
each commit) but you can jump around among individual builds.

You can see a list of all completed builds on our Hudson server:
http://build.clojure.org/view/Clojure/job/clojure/

The module builds pages show the Git commit messages and corresponding 
snapshot version number:
http://build.clojure.org/view/Clojure/job/clojure/318/org.clojure$clojure/

With Git post-commit hooks, we could theoretically ensure there is always a 
snapshot build corresponding to each commit.

-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: Get key from map

2011-10-24 Thread Alan Malloy
http://stackoverflow.com/q/7034803/625403

On Oct 24, 2:58 pm, pistacchio pistacc...@gmail.com wrote:
 Hi! Since both (:a {:a 1 :b 2}) and ({:a 1 :b 2} :a) return the
 correct value, is there any difference between the two? What is the
 preferred form?

 Thanks.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: aquamacs, slime and clojure on OS X

2011-10-24 Thread Roberto Mannai
Confirm, as Jake said it is enough to delete the folder
/Library/Application Support/Aquamacs Emacs/SLIME/; my problem was
probably derived from having previously installed also
Aquamacs-SLIME-2011-xxx.pkg.tgz, the SLIME plugin from
http://aquamacs.org/download.shtml.

(Lein's swank plugin uses an embedded slime.el - check
swank-clojure-1.4.0-SNAPSHOT.jar\swank\payload)

On Mon, Sep 26, 2011 at 2:56 AM, Roberto Mannai roberm...@gmail.com wrote:

 I have some trouble. I'm on OSX Lion, and have a few hours ago
 installed Aquamacs and SLIME from http://aquamacs.org/download.shtml.
 Then installed lein/swank/and clojure-mode, as Phil suggested.

 In order to make it work I had to remove the autodoc option, by
 commenting line 20 from /Library/Application Support/Aquamacs
 Emacs/SLIME/contrib/slime-fancy.el:
 ;(slime-autodoc-init)

 So by starting swank manually with lein swank (or swank-clojure) +
 M-x slime-connect I can now evaluate Clojure code in the REPL; instead
 when doing a clojure-jack-in I get the following error:

 (from *Messages* buffer)
  Starting swank server...
  error in process filter: progn: Invalid read syntax: )
  error in process filter: Invalid read syntax: )

 (last lines from *swank* buffer)
  (provide 'slime-repl)
  ;;; slime-repl.el ends here
  (run-hooks 'slime-load-hook)

 Any idea?

 On Sun, Sep 25, 2011 at 5:52 PM, László Török ltoro...@gmail.com wrote:
  +1 for me too on Snow Leopard with latest Aquamacs
 
  2011/9/23 Durgesh Mankekar durg...@gmail.com
 
  +1 here. These instructions have worked for me with Aquamacs.
  On Sep 23, 2011, at 2:46 PM, Justin Kramer wrote:
 
    * install Leiningen
    * install the swank-clojure plugin: lein plugin install swank-clojure
  1.3.2
    * install clojure-mode (you can do this from git)
    * navigate to a project and do M-x clojure-jack-in
 
  That's all it takes. It might work with Aquamacs, but since that fork
  is not portable it's impossible for me to test on it. So GNU Emacs is
  recommended.
 
  For what it's worth, I use this setup with Aquamacs and everything works
  perfectly.
  Justin
  --
  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
 
 
  --
  László Török
  Skype: laczoka2000
  Twitter: @laczoka
 
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient with your
  first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en

-- 
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: trouble setting up emacs

2011-10-24 Thread Roberto Mannai
It seems you're having some problems with incompatible slime versions.
On Mac I'm successfully using Acquamacs
(http://aquamacs.org/download.shtml - do NOT install
Aquamacs-SLIME-xx.pkg.tgz) without any particular workaround. Just
install it, install lein (my script is /usr/bin/lein) and the
clojure-mode. See also
http://groups.google.com/group/clojure/browse_thread/thread/986227536292502b?hl=en

On Tue, Oct 25, 2011 at 2:06 AM, Howard Lewis Ship hls...@gmail.com wrote:
 So Swank appears to be running, but when I edit a Clojure file and hit
 C-x C-e I get an error:

 Symbol's function definition is void: lisp-eval-last-sexp

 I also see this in my *messages* buffer:

 error in process filter: require: Symbol's value as variable is void: 
 slime-clj

 Any ideas ... even on where to start?



 On Mon, Oct 24, 2011 at 4:55 PM, Howard Lewis Ship hls...@gmail.com wrote:
 This was helpful:

 http://www.emacswiki.org/emacs/MacOSTweaks#toc14

 I added the following to my init.el:

 (setenv PATH (concat (getenv PATH) :~/bin))
 (setq exec-path (append exec-path `(~/bin)))


 Seems like I could have used (add-to-list 'exec-path ~/bin) for the
 second line, is that right?

 In any case, my next step is to see if Swank is working (it would help
 if I knew what Swank was supposed to do!)

 On Mon, Oct 24, 2011 at 4:33 PM, Phil Hagelberg p...@hagelb.org wrote:
 On Mon, Oct 24, 2011 at 4:28 PM, Howard Lewis Ship hls...@gmail.com wrote:
 lein is on my search path (in ~/bin).  Where do I update things so
 that it is on the path for the Swank process?

 In Mac OS X, usually programs that are launched from the GUI don't get
 their environment variables (like $PATH) set correctly. Supposedly
 there's a fix, but it involves editing a file called plist.xml, so I
 have a hard time recommending it with a clear conscience.

 -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



 --
 Howard M. Lewis Ship

 Creator of Apache Tapestry

 The source for Tapestry training, mentoring and support. Contact me to
 learn how I can get you up and productive in Tapestry fast!

 (971) 678-5210
 http://howardlewisship.com




 --
 Howard M. Lewis Ship

 Creator of Apache Tapestry

 The source for Tapestry training, mentoring and support. Contact me to
 learn how I can get you up and productive in Tapestry fast!

 (971) 678-5210
 http://howardlewisship.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


ClojureScript: Emacs Inferior Lisp Windows Batch Script

2011-10-24 Thread Matt Hoyt
I modified the repljs.bat to include the current directory src/clj, src/cljs, 
lib/, test/cljs, and test/clj to use with emacs inferior lisp mode in Windows.

https://gist.github.com/1310468

Matt Hoyt

-- 
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: trouble setting up emacs

2011-10-24 Thread Phil Hagelberg
On Mon, Oct 24, 2011 at 5:06 PM, Howard Lewis Ship hls...@gmail.com wrote:
 error in process filter: require: Symbol's value as variable is void: 
 slime-clj

slime-clj is a different poorly-named library that has been renamed to
ritz. Unfortunately the packages are still available for installation.

The swank-clojure readme should cover everything you need as long as
you don't have any other incompatible libraries (like swank-clj or the
CL-compatible version of slime) installed:
https://github.com/technomancy/swank-clojure/blob/1.3.x/README.md The
only piece of elisp you should install is clojure-mode.

-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


where do you put clojure.java.jdbc?????

2011-10-24 Thread jayvandal
I am running Vista. I installed Clojure as c:\clojure.
Where and how do you put the file

[org.clojure/java.jdbc 0.0.3-SNAPSHOT]]

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


R.I.P. John McCarthy

2011-10-24 Thread finbeu
John McCarthy, the father of Lisp, died last night at the age of 84.

-- 
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: R.I.P. John McCarthy

2011-10-24 Thread Baishampayan Ghose
 John McCarthy, the father of Lisp, died last night at the age of 84.

Here lies a Lisper
Uninterned from this mortal package
Yet not gc'd
While we retain pointers to his memory

Source - https://twitter.com/#!/mtraven/status/128603266933198848

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.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: clojure starter package for aichallenge ?

2011-10-24 Thread Sunil S Nandihalli
Hi Ulises,
 I get a bad submission key found error when I submit the zip file that
contains
ants.clj
MyBot.clj

Am I doing something wrong?

I did run the test_bot.sh with MyBot.clj .. It seems to work fine.

Thanks,
Sunil.



On Tue, Oct 25, 2011 at 3:52 AM, Ulises ulises.cerv...@gmail.com wrote:

 I tried submitting the started package and it crashed as hills weren't
 implemented.

 I have patched the starter package to include hills (although I
 suspect I'm doing the wrong thing; I blindly copied the behaviour of
 keeping track of the coords for hills too).

 The code resides in: https://github.com/ulises/ai-challenge

 PS: I just submitted it and it passed all tests.

 U

 --
 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: clojure starter package for aichallenge ?

2011-10-24 Thread Sunil S Nandihalli
I failed to mention that both the files are in a directory named

mybot



On Tue, Oct 25, 2011 at 10:58 AM, Sunil S Nandihalli 
sunil.nandiha...@gmail.com wrote:

 Hi Ulises,
  I get a bad submission key found error when I submit the zip file that
 contains
 ants.clj
 MyBot.clj

 Am I doing something wrong?

 I did run the test_bot.sh with MyBot.clj .. It seems to work fine.

 Thanks,
 Sunil.



 On Tue, Oct 25, 2011 at 3:52 AM, Ulises ulises.cerv...@gmail.com wrote:

 I tried submitting the started package and it crashed as hills weren't
 implemented.

 I have patched the starter package to include hills (although I
 suspect I'm doing the wrong thing; I blindly copied the behaviour of
 keeping track of the coords for hills too).

 The code resides in: https://github.com/ulises/ai-challenge

 PS: I just submitted it and it passed all tests.

 U

 --
 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: R.I.P. John McCarthy

2011-10-24 Thread Sreenivas Reddy T
Hi all,
  though i am at the early stages of clojure, i think it is right
time to share our fellow clojurian conversation with The  Great McCarthy.
Here is the link..
http://nathanmarz.com/blog/my-conversation-with-the-great-john-mccarthy.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: where do you put clojure.java.jdbc?????

2011-10-24 Thread Sean Corfield
On Mon, Oct 24, 2011 at 8:36 PM, jayvandal s...@ida.net wrote:
 I am running Vista. I installed Clojure as c:\clojure.

You don't need to install Clojure if you're using Leiningen (and I'd
recommend you use Leiningen for managing project dependencies).

 Where and how do you put the file

 [org.clojure/java.jdbc 0.0.3-SNAPSHOT]]

In project.clj (see Leiningen above) - and 0.1.0 is the current
version of c.j.jdbc.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.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