Re: Clojure script with shebangoid on windows

2010-05-31 Thread alux
Ah!

Hello Glen, good hint. Problem and solution reproduced ;-)

Thank you,

greetings, alux


On 31 Mai, 06:00, Glen Stampoultzis gst...@gmail.com wrote:
 On 31 May 2010 04:51, Paul Moore p.f.mo...@gmail.com wrote:

  On 30 May 2010 12:31, alux alu...@googlemail.com wrote:
   Small addition, you missed to add the : before eof

   replace goto eof by goto :eof

  Thanks, good catch. (goto eof without the colon works on TCC, which
  I normally use as my command shell).

 I noticed it seemed to have problems when trying to use an absolute path to
 reference clojure.jar.

 java -cp d:\products\clojure\clojure.jar clojure.main %~f0 %*

 Using forward slashes instead seemed to do the trick.

-- 
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: special forms and let binding

2010-05-31 Thread alux
Hello ataggart,

thank you for the correction!
Only now I understand A.Rosts question. May be somebody can help, and
explain why my hypothesis was wrong. Obviousely, while functions are
first class, special forms are even better, kind of zeroth class.

Thank you, alux


On 31 Mai, 04:15, ataggart alex.tagg...@gmail.com wrote:
 On May 30, 12:45 pm, alux alu...@googlemail.com wrote:

  Hi A.,

  I dont completely understand what you refer to with works correct.

  You define a local variable, named do, and use it.  That works of
  course. Btw you may use it without the call to var
  (def do println)
  (do example)

 It only appears to work; the second line is still using the special
 form.  You can see this more clearly here:

 user= (def if println)
 #'user/if
 user= (if hi)
 java.lang.Exception: Too few arguments to if (NO_SOURCE_FILE:22)
 user= ((var if) hi)
 hi
 nil

 The hi is from the println function, the nil is what was returned
 from the call.

-- 
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: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-31 Thread Quzanti
+1 Swing with caveats

Will Swing itself continue to receive serious backing from Oracle?
Will they get JavaFX to do everything Swing can and then deprecate
Swing (if not officially then in practice?) It really depends on
Netbeans. All the LF issues and other minor ones got attention when
Sun began eating its own dogfood and developing Netbeans with Swing.
Although having said that is JDeveloper built on top of Swing or SWT -
I think probably Swing as JBuilder was so Swing wins whichever tool
Oracle eventually standardises on.

An example of the point I am trying to make is resolution
independence. There was a big push for resolution independence in
Swing, which got a long way, but then since JavaFX came along all
efforts in that area seem to have been JavaFX focussed.

On May 27, 4:32 pm, Sean Devlin francoisdev...@gmail.com wrote:
 +1 Swing.  There's a ton of documentation out there, and it got some
 serious love from Sun between java 5 and 6.

 On May 27, 11:27 am, Laurent PETIT laurent.pe...@gmail.com wrote:

  Although I work with SWT at work, I would say Swing for 2 reasons :

    * no additional dependency for users of your lib, and *no need* for users
  of your lib to deliver different final apps binaries for different platforms
    * may be easier to work with in your implementation (?)

  2010/5/27 Luke VanderHart luke.vanderh...@gmail.com

   My side project is a fairly complex GUI application written in
   Clojure. Recently, I've become irritated with using Java interop for
   everything. It's not that Clojure doesn't have nice java interop - it
   does. It's just that when interacting with a GUI framework, which is a
   large part of my app, I have to be back in mutable object-oriented
   land, worrying about class hierarchies, mutable state, locks, etc.
   Yucky.

   So, with a perhaps dangerous lack of sanity and without any guarantee
   of success, I've decided to try my hand at writing an idiomatic
   Clojure GUI library. If I have success (which I doubt) I will of
   course make it available as open source.

   I intend for it to be mostly declarative, with a nice DSL for defining
   GUI elements. Each component will also implement map, and use one of
   Clojure's reference types as an interface for inspecting / updating
   its state. I may also implement some aspects of Functional Reactive
   Programming wherever it's convenient to do so.

   What you all must help me decide is what GUI framework to use as the
   underpinnings of it. It's genuinely hard to decide. I have at least
   some experience with all of them, so I have no strong preference, but
   I'd like to get your input. I did consider trying to make it abstract
   enough that you could plug in *any* of them under the hood, but
   there's enough differences between the frameworks that that would get
   very ugly very fast.

   Possibilities are:

   AWT
   Pros: native widgets, bundled with Java, low-level
   Cons: few widgets, considered somewhat obselete

   Swing
   Pros: bundled with Java, good widget selection
   Cons: non-native widgets

   SWT
   Pros: native widgets, widely used
   Cons: requires platform-specific libs

   QT Jambi
   Pros: native widgets, huge widget selection, highly-regarded framework
   Cons: requires platform-specific libs, writing custom widgets is
   hairy, momentum and support seem to be lagging since Nokia dropped
   official support.

   Remember, the actual API won't matter - that will be completely
   abstracted away. So try to focus on the framework's look and feel.
   Also let me know if I've missed any of the framework's key
   characteristics.

   Thanks!

   -Luke

   --
   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.comclojure%2bunsubscr...@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: Rationals, and their size

2010-05-31 Thread alux
Ah, thank you - I still shy away from looking into Richs sources, but
here it helps: Ratio doesn't have getter for numerator and denominator
- they are just public ;-)

Being final thats okay of course.

So. Whether this helps, I dont know too. I still dont have the lever,
but now I have a point to place it at ;-)

Regards, alux


On 31 Mai, 04:10, ataggart alex.tagg...@gmail.com wrote:
 Ratio doesn't emit the numerator and 
 denominator:http://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lang...

 I'm not sure that would help solve your problem, even if it were
 available.  You either need to turn the ratio into a non-ratio (using
 float or double) or use unchecked math functions which are subject to
 truncation (e.g., unchecked-multiply).

 On May 30, 1:32 pm, alux alu...@googlemail.com wrote:

  Hello,

  I careless used rationals in a function, and, well, it took some
  minutes to understand why it was slowing down. (I did this formatting
  by (println (* 1.0 x)) when it started being unreadable - and forgot
  that).

  I still see rationals as very nice, but try to use them carefully now.
  What I would really like is a possibility to round to a numer of a
  certain size. Like, to an continued fraction of a certain size. But,
  there I need access to the length of numerator and denominator.

  Now the question - is there any way to access this (or to reach to
  goal of rounding to a rational), that is easier than using the
  BigIntegers myself?

  Thank you, alux

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


special form vs. macro

2010-05-31 Thread alux
Hi,

I got a very basic question about the concept of special form. What
is correct, multiple selections allowed:

[  ] A special form is what can be implemented by a macro.

[  ] Every macro gives a special form.

[  ] Only a macro that doesn't evaluate some of its arguments gives a
special form.

[  ] A special form is always built in, and cannot be implemented in
the language itself.

[  ] Special forms are exactly the things that can be called, but dont
evaluate all of their arguments. (Macros and build-ins, at least for
eager languages.)

[  ] The concept of special form doesnt have anything to do with
eagerness or lazyness.

[  ] You are completely wrong, the right question is:


Thank you, alux

-- 
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: Datatype Usage Examples

2010-05-31 Thread Sina K. Heshmati
Sina K. Heshmati wrote:
 Meikel Brandmeyer wrote:
 Am 30.05.2010 um 16:39 schrieb Sina K. Heshmati:

 I'll later try to see if I can export datatypes from within a closure.

The atomic 'state' doesn't seem to be visible to the datatype methods. The 
question is why?

(defprotocol prot-a
  (op-a [self x y]))

(let [state (atom 10)]
  (deftype t-a [member]
prot-a
(op-a [self x y]
  (+ (.member self) x y @state

(def t-a-instance (t-a. 5))

This example is in:
http://github.com/sindoc/algorithms/blob/master/src/test/clojure/whiteboard/y2010/hide-adt-state/datatype-in-closure-01.clj

Thank you in advance,
SinDoc

-- 
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: Datatype Usage Examples

2010-05-31 Thread Meikel Brandmeyer
Hi,

On May 31, 9:37 am, Sina K. Heshmati s...@khakbaz.com wrote:

 The atomic 'state' doesn't seem to be visible to the datatype methods. The 
 question is why?

 (defprotocol prot-a
   (op-a [self x y]))

 (let [state (atom 10)]
   (deftype t-a [member]
     prot-a
     (op-a [self x y]
       (+ (.member self) x y @state

 (def t-a-instance (t-a. 5))

Of course not. deftype defines a type and not an environment. It's
methods are not closures. (And even if they were, your state would be
the same for all instances.) You have to pass the state as an argument
to the constructor.

(defprotocol prot-a ...)
(deftype t-a [state member] ...)

(defn make-t-a [member] (t-a. (atom 0) member))

(def t-a-instance (make-t-a 5))

If you actually want the same state for instances, use a private var.

(defprotocol prot-a ...)
(def ^{:private true} state (atom 0))
(deftype t-a [member] ...)

(def t-a-instance (t-a. 5))

Sincerely
Meikel


Sincerely
Meikel

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


Evaluated once or on each function call?

2010-05-31 Thread Michael Jaaka
Is that let expression helps?

(let [word (*cfg* :word)]
 (filter #(= word %) [ tom eat ]))

or this is exactly the same

  (filter #(= (*cfg* :word) %) [ tom eat ])

note that *cfg* is a thread binded hash map

-- 
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: special form vs. macro

2010-05-31 Thread Konrad Hinsen

On 31 May 2010, at 09:35, alux wrote:


I got a very basic question about the concept of special form. What
is correct, multiple selections allowed:

[  ] A special form is what can be implemented by a macro.


Wrong. You cannot implement a Lisp-like language with just macros and  
functions. At some point the operations defined by macros and  
functions must be reduced to fundamental operations that are handled  
directly by the compiler.


Example: if and cond. You can implement either one in terms of the  
other one as a macro, but you cannot implement *both* as macros.



[  ] Every macro gives a special form.


Wrong. A macro rewrites a form to another form. A special form is  
interpreted directly by the compiler.


There is also a technical difference: a macro is the value of a name,  
which is looked up in the context of the macro call. Constructs like  
macrolet (clojure.contrib.macro-utils) permit local macro definitions,  
for example. A special form is named by a symbol whose interpretation  
cannot be overridden in any way.



[  ] Only a macro that doesn't evaluate some of its arguments gives a
special form.


Wrong as well. The distinction between macros and special forms is a  
matter of implementation, not of evaluating arguments.



[  ] A special form is always built in, and cannot be implemented in
the language itself.


True for a minimalist language implementation. An implementation may  
choose to use more special forms than strictly necessary for  
performance reasons.



[  ] The concept of special form doesnt have anything to do with
eagerness or lazyness.


True.

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: Evaluated once or on each function call?

2010-05-31 Thread Konrad Hinsen

On 31 May 2010, at 10:28, Michael Jaaka wrote:


Is that let expression helps?

(let [word (*cfg* :word)]
(filter #(= word %) [ tom eat ]))

or this is exactly the same

 (filter #(= (*cfg* :word) %) [ tom eat ])

note that *cfg* is a thread binded hash map


The two expressions are equivalent. However, there is a difference  
when you use let outside of a function definition:


(defn filter-words [words]
  (filter #(= (*cfg* :word) %) words))

This looks the value corresponding to the key :word at each function  
call.


(let [word (*cfg* :word)]
  (defn filter-words [words]
(filter #(= word %) words)))

This looks up the value corresponding to :word once, when the function  
is defined, and uses that same value whenever the function is called.


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: special form vs. macro

2010-05-31 Thread Jarkko Oranen
On May 31, 10:35 am, alux alu...@googlemail.com wrote:

 [  ] A special form is what can be implemented by a macro.

That depends. My understanding is that a special form is something
that is fundamental to the language, that the evaluator handles as a
special case. That is, they need to be implemented in the compiler/
interpreter itself. However, in practice you can't really tell the
difference between a macro and a special form, and in fact some
Clojure special forms are implemented as macros (on top of a real
special form that is an implementation detail)


 [  ] Every macro gives a special form.

Not really. All macros have the same evaluation semantics (macro
expansion).

 [  ] Only a macro that doesn't evaluate some of its arguments gives a
 special form.

I don't think evaluation of arguments matters.


 [  ] A special form is always built in, and cannot be implemented in
 the language itself.

That depends on your point of view, but in general, yes.


 [  ] Special forms are exactly the things that can be called, but dont
 evaluate all of their arguments. (Macros and build-ins, at least for
 eager languages.)

Special forms are special because the evaluator has separate
evaluation rules for each of them. Other than that, they are merely
another kind of operator (the others being macros and functions)


 [  ] The concept of special form doesnt have anything to do with
 eagerness or lazyness.

This is correct.

-- 
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: Evaluated once or on each function call?

2010-05-31 Thread Meikel Brandmeyer
Hi,

On May 31, 10:43 am, Konrad Hinsen konrad.hin...@fastmail.net wrote:

 The two expressions are equivalent. However, there is a difference  
 when you use let outside of a function definition:

I disagree. The two expressions are not equivalent and you actually
provide the explanation, why they are not. The defn does really make a
difference. (#() is the defn)

user= (def *cfg* {:word tom})
#'user/*cfg*
user= (def s (filter #(= (:word *cfg*) %) (list tom eat)))
#'user/s
user= (def t (let [word (:word *cfg*)] (filter #(= word %) (list
tom eat
#'user/t
user= [(first s) (first t)]
[tom tom]
user= (binding [*cfg* {:word eat}] [(fnext s) (fnext t)])
[eat nil]

Note: I use list instead of the usual vector to avoid chunked seq
evaluation.

Sincerely
Meikel

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


Re: Datatype Usage Examples

2010-05-31 Thread Sina K. Heshmati
Meikel Brandmeyer m...@kotka.de said:
 On May 31, 9:37 am, Sina K. Heshmati s...@khakbaz.com wrote:
 
 The atomic 'state' doesn't seem to be visible to the datatype methods. The
 question is why?

 (defprotocol prot-a
   (op-a [self x y]))

 (let [state (atom 10)]
   (deftype t-a [member]
     prot-a
     (op-a [self x y]
       (+ (.member self) x y @state

 (def t-a-instance (t-a. 5))
 
 Of course not. deftype defines a type and not an environment. It's
 methods are not closures. (And even if they were, your state would be
 the same for all instances.) You have to pass the state as an argument
 to the constructor.

Now it makes more sense. Thanks.

 (defprotocol prot-a ...)
 (deftype t-a [state member] ...)
 
 (defn make-t-a [member] (t-a. (atom 0) member))
 
 (def t-a-instance (make-t-a 5))

I'll pass.

 If you actually want the same state for instances, use a private var.
 
 (defprotocol prot-a ...)
 (def ^{:private true} state (atom 0))
 (deftype t-a [member] ...)
 
 (def t-a-instance (t-a. 5))

This is a pretty solution but I tested it and it doesn't work the way it 
should. That is, when I load [1] in a separate REPL, I can still see and 
(reset!) the allegedly private 'state'.

user= (load-file path/tp/datatype-01.clj)
#'foo.datatype-01/t-a-instance
user= (ns PREFIX.datatype-01)
nil
foo.datatype-01 = (op-a t-a-instance 1 2)
18
foo.datatype-01 = state
#a...@302e67: 10
foo.datatype-01 = @state
10
foo.datatype-01 = (reset! state 13)
13
foo.datatype-01 = @state
13

Kind regards,
SinDoc

[1] 
http://github.com/sindoc/algorithms/blob/master/src/main/clojure/whiteboard/y2010/hide-adt-state/datatype-01.clj

-- 
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: Datatype Usage Examples

2010-05-31 Thread Meikel Brandmeyer
Hi,

On May 31, 10:58 am, Sina K. Heshmati s...@khakbaz.com wrote:

 foo.datatype-01 = (reset! state 13)
  ^^^

Again: of course you can! You are in the same namespace! In Clojure
the unit is a namespace and not a type. If you want this level
privateness you have to use one namespace per type. However this is
not really the Clojure Way.

Sincerely
Meikel

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


Re: special form vs. macro

2010-05-31 Thread alux
Hello Konrad, many thanks, that clarifies it!

So, in A special form is always built in, and cannot be implemented
in the language itself. the first part is true, the second is not.
Like most lisps have a bilt in list-reverse for speed reasons.
In that case, this build in thing is a special form that can also be
implemented in the language (only slow).
Right?


A special form is named by a symbol whose interpretation
cannot be overridden in any way.

This explains the problem from another thread (that made me ask this
question in the first place):

user= (def do println)
#'user/do

; this uses the special form
user= (do huhu plop)
plop

; while this uses println
user= ((var do) huhu hello)
huhu hello
nil


Thank you, alux

On 31 Mai, 10:38, Konrad Hinsen konrad.hin...@fastmail.net wrote:
 On 31 May 2010, at 09:35, alux wrote:

  I got a very basic question about the concept of special form. What
  is correct, multiple selections allowed:

  [  ] A special form is what can be implemented by a macro.

 Wrong. You cannot implement a Lisp-like language with just macros and  
 functions. At some point the operations defined by macros and  
 functions must be reduced to fundamental operations that are handled  
 directly by the compiler.

 Example: if and cond. You can implement either one in terms of the  
 other one as a macro, but you cannot implement *both* as macros.

  [  ] Every macro gives a special form.

 Wrong. A macro rewrites a form to another form. A special form is  
 interpreted directly by the compiler.

 There is also a technical difference: a macro is the value of a name,  
 which is looked up in the context of the macro call. Constructs like  
 macrolet (clojure.contrib.macro-utils) permit local macro definitions,  
 for example. A special form is named by a symbol whose interpretation  
 cannot be overridden in any way.

  [  ] Only a macro that doesn't evaluate some of its arguments gives a
  special form.

 Wrong as well. The distinction between macros and special forms is a  
 matter of implementation, not of evaluating arguments.

  [  ] A special form is always built in, and cannot be implemented in
  the language itself.

 True for a minimalist language implementation. An implementation may  
 choose to use more special forms than strictly necessary for  
 performance reasons.

  [  ] The concept of special form doesnt have anything to do with
  eagerness or lazyness.

 True.

 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: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-31 Thread Jeff Rose
We would definitely be interested in using something like this for
Project Overtone. (http://project-overtone.org)  We have already
migrated from directly using Swing with the built-in Java interop, to
creating a thin layer of clojure functions to trim out the boiler
plate, to now wishing we had something more idiomatic.

Swing without question.  People who are complaining about the look
haven't explored what you can do with the pluggable look and feel
system.  For example, try the demo on the substance page, where they
have a variety of different themes implemented:

https://substance.dev.java.net/

My guess is that using Swing will get the library used by vastly more
applications, because it will be available as a quick GUI for little
utilities and sample apps, as well as full fledged applications.
Nobody is going to deal with the pain of SWT unless they have a
serious app to build, and even then deployment is a total pain.  And
no, it isn't a one time thing.  Dealing with cross platform, native
code is an ongoing process that continues to be annoying every time
any one of the host platforms upgrades the GUI libraries.  Just think,
how often does one of windows, mac or linux upgrade the libraries?

The much more interesting conversation is about the style of library
you are envisioning.  Although it would require a small dependency,
one thing I would think about doing is using the MigLayout engine for
all layout functionality, under the hood.  It provides you with the
capabilities of all the Swing layout engines, but the interface is
straight forward and makes it easy to evolve your GUI overtime without
having to keep shifting which type of layout classes you are using.

Probably the two key aspects of the library design are going to be the
way you register for and handle events, and the way you update widget
state.  Dangling references to widgets is also a typical source of
memory leaks, so finding a way to cleanly keep track of widgets and
get rid of them once they are not needed is going to be valuable.  In
Overtone we have been using a simple event system that lets you
register for events (namespaced keywords), and emit them easily.  This
works pretty well, although it isn't the easiest kind of code to
debug.  How would a functional reactive style library work?

On May 27, 5:18 pm, Luke VanderHart luke.vanderh...@gmail.com wrote:
 My side project is a fairly complex GUI application written in
 Clojure. Recently, I've become irritated with using Java interop for
 everything. It's not that Clojure doesn't have nice java interop - it
 does. It's just that when interacting with a GUI framework, which is a
 large part of my app, I have to be back in mutable object-oriented
 land, worrying about class hierarchies, mutable state, locks, etc.
 Yucky.

 So, with a perhaps dangerous lack of sanity and without any guarantee
 of success, I've decided to try my hand at writing an idiomatic
 Clojure GUI library. If I have success (which I doubt) I will of
 course make it available as open source.

 I intend for it to be mostly declarative, with a nice DSL for defining
 GUI elements. Each component will also implement map, and use one of
 Clojure's reference types as an interface for inspecting / updating
 its state. I may also implement some aspects of Functional Reactive
 Programming wherever it's convenient to do so.

 What you all must help me decide is what GUI framework to use as the
 underpinnings of it. It's genuinely hard to decide. I have at least
 some experience with all of them, so I have no strong preference, but
 I'd like to get your input. I did consider trying to make it abstract
 enough that you could plug in *any* of them under the hood, but
 there's enough differences between the frameworks that that would get
 very ugly very fast.

 Possibilities are:

 AWT
 Pros: native widgets, bundled with Java, low-level
 Cons: few widgets, considered somewhat obselete

 Swing
 Pros: bundled with Java, good widget selection
 Cons: non-native widgets

 SWT
 Pros: native widgets, widely used
 Cons: requires platform-specific libs

 QT Jambi
 Pros: native widgets, huge widget selection, highly-regarded framework
 Cons: requires platform-specific libs, writing custom widgets is
 hairy, momentum and support seem to be lagging since Nokia dropped
 official support.

 Remember, the actual API won't matter - that will be completely
 abstracted away. So try to focus on the framework's look and feel.
 Also let me know if I've missed any of the framework's key
 characteristics.

 Thanks!

 -Luke

-- 
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: special form vs. macro

2010-05-31 Thread Konrad Hinsen

On 31 May 2010, at 11:08, alux wrote:


Hello Konrad, many thanks, that clarifies it!

So, in A special form is always built in, and cannot be implemented
in the language itself. the first part is true, the second is not.
Like most lisps have a bilt in list-reverse for speed reasons.
In that case, this build in thing is a special form that can also be
implemented in the language (only slow).
Right?


Right.


A special form is named by a symbol whose interpretation
cannot be overridden in any way.

This explains the problem from another thread (that made me ask this
question in the first place):

user= (def do println)
#'user/do

; this uses the special form
user= (do huhu plop)
plop

; while this uses println
user= ((var do) huhu hello)
huhu hello
nil


Yes, that illustrates the handling of special forms nicely. Note that  
it is somewhat specific to Clojure. Other Lisps handle the mapping  
from symbols to functions/macros/special forms differently.


One more variant is helpful:

user= (user/do huhu hello)
huhu hello
nil

This illustrates that special forms need to be identified by an  
unqualified symbol in the operator position.


Another detail that is good to know is that syntax-quote (`) knows  
about special forms and treats their symbols specially even if they  
are not in the operator position:


user= (declare do foo)
#'user/foo
user= `do
do
user= `foo
user/foo

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: Evaluated once or on each function call?

2010-05-31 Thread Konrad Hinsen

On 31 May 2010, at 10:53, Meikel Brandmeyer wrote:


The two expressions are equivalent. However, there is a difference
when you use let outside of a function definition:


I disagree. The two expressions are not equivalent and you actually
provide the explanation, why they are not. The defn does really make a
difference. (#() is the defn)


Oops... Right, I didn't see the #!

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


How to make that eval could see its caller context

2010-05-31 Thread Michael Jaaka
Hello,

I would like to make that eval see context of the caller block.
In the example:

(defn my-if [a b c]
(let [z (name (gensym)) t (symbol (str z true)) f (symbol (str z
false)) ]
(def t (fn[] b))
(def f (fn[] c))
(def mycond (boolean a))
((eval (symbol (str z mycond))


the symbol can't be found in context represented by the eval. What to
do to make it working?

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: Evaluated once or on each function call?

2010-05-31 Thread Michael Jaaka
Thanks, I just wanted to know if keyword hashmap is evaluated on each time.
You have answered my question. Thanks again.

-- 
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: special form vs. macro

2010-05-31 Thread Sina K. Heshmati
alux alu...@googlemail.com said:

 I got a very basic question about the concept of special form. What
 is correct, multiple selections allowed:
 
 [  ] A special form is what can be implemented by a macro.

Wrong. Macros cannot remove the need for special-forms, at least not in a real 
interpreter. In a metacircular implementation, you can replace special-forms 
with calls to the base-level implementation. For instance, if you evaluate 'if' 
at base-level, then you can use it to define 'cond' at base-level.

 [  ] Every macro gives a special form.

They can all be reduced to a number of expressions that cannot be implemented 
by neither macros nor functions. 

These expressions can be evaluated using normal functions if you have lazy 
evaluation of arguments. So, if you have lazy-eval, there's no need for 
special-forms.

 [  ] Only a macro that doesn't evaluate some of its arguments gives a
 special form.

You could say that.

 [  ] A special form is always built in, and cannot be implemented in
 the language itself.

Unless you have lazy-eval.

 [  ] Special forms are exactly the things that can be called, but dont
 evaluate all of their arguments. (Macros and build-ins, at least for
 eager languages.)
 
 [  ] The concept of special form doesnt have anything to do with
 eagerness or lazyness.

Wrong. It has everything to do with laziness. If you have one, you don't need 
the other.

Please note that, the concept of special-forms is a compromise and I don't 
think anyone would want to have them. A language designer has to make a choice 
as to whether to have special forms or not. If they don't want special-forms, 
then they should provide lazy evaluation of arguments.

Some introduce functional parameters in order to provide lazy evaluation of 
arguments but that choice has its own trade-offs since it introduces a kind of 
dynamic scoping.

Kind regards,
SinDoc

-- 
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: special form vs. macro

2010-05-31 Thread Sina K. Heshmati
Sina K. Heshmati s...@khakbaz.com said:
 alux alu...@googlemail.com said:
 
 I got a very basic question about the concept of special form. What
 is correct, multiple selections allowed:

 [  ] A special form is what can be implemented by a macro.
 
 Wrong. Macros cannot remove the need for special-forms, at least not in a real
 interpreter. In a metacircular implementation, you can replace special-forms 
 with
 calls to the base-level implementation. For instance, if you evaluate 'if' at
 base-level, then you can use it to define 'cond' at base-level.

Oh, I meant:
... then you can use it to define 'cond' at *meta*-level.

 [  ] Every macro gives a special form.
 
 They can all be reduced to a number of expressions that cannot be implemented 
 by
 neither macros nor functions.
 
 These expressions can be evaluated using normal functions if you have lazy
 evaluation of arguments. So, if you have lazy-eval, there's no need for
 special-forms.
 
 [  ] Only a macro that doesn't evaluate some of its arguments gives a
 special form.
 
 You could say that.
 
 [  ] A special form is always built in, and cannot be implemented in
 the language itself.
 
 Unless you have lazy-eval.
 
 [  ] Special forms are exactly the things that can be called, but dont
 evaluate all of their arguments. (Macros and build-ins, at least for
 eager languages.)

 [  ] The concept of special form doesnt have anything to do with
 eagerness or lazyness.
 
 Wrong. It has everything to do with laziness. If you have one, you don't need 
 the
 other.
 
 Please note that, the concept of special-forms is a compromise and I don't 
 think
 anyone would want to have them. A language designer has to make a choice as to
 whether to have special forms or not. If they don't want special-forms, then 
 they
 should provide lazy evaluation of arguments.
 
 Some introduce functional parameters in order to provide lazy evaluation of
 arguments but that choice has its own trade-offs since it introduces a kind of
 dynamic scoping.
 
 Kind regards,
 SinDoc

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


Re: How to make that eval could see its caller context

2010-05-31 Thread Joost
On May 31, 12:03 pm, Michael Jaaka michael.ja...@googlemail.com
wrote:
 Hello,

 I would like to make that eval see context of the caller block.
 In the example:

 (defn my-if [a b c]
         (let [z (name (gensym)) t (symbol (str z true)) f (symbol (str z
 false)) ]
                 (def t (fn[] b))
                 (def f (fn[] c))
                 (def mycond (boolean a))
                 ((eval (symbol (str z mycond))

 the symbol can't be found in context represented by the eval. What to
 do to make it working?

Practically all of the time you need to solve this kind of problem,
you can use a map with symbol - value pairs instead of adding bunch
of  variable definitions to the environment. And it usually turns out
once you do this you don't even need to (eval) anything anymore.

You also *really* do not want to redefine globals in a function body
if you have any pretense of doing functional code. Why don't you use
(let []) instead?

Joost.

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


Re: How to make that eval could see its caller context

2010-05-31 Thread Michael Jaaka
Well, this is just an example.
I need to refer to global vars from eval.
One solution is to define these vars in eval form,
but I would like to omit that step.

On 31 Maj, 12:53, Joost jo...@zeekat.nl wrote:
 On May 31, 12:03 pm, Michael Jaaka michael.ja...@googlemail.com
 wrote:

  Hello,

  I would like to make that eval see context of the caller block.
  In the example:

  (defn my-if [a b c]
          (let [z (name (gensym)) t (symbol (str z true)) f (symbol (str z
  false)) ]
                  (def t (fn[] b))
                  (def f (fn[] c))
                  (def mycond (boolean a))
                  ((eval (symbol (str z mycond))

  the symbol can't be found in context represented by the eval. What to
  do to make it working?

 Practically all of the time you need to solve this kind of problem,
 you can use a map with symbol - value pairs instead of adding bunch
 of  variable definitions to the environment. And it usually turns out
 once you do this you don't even need to (eval) anything anymore.

 You also *really* do not want to redefine globals in a function body
 if you have any pretense of doing functional code. Why don't you use
 (let []) instead?

 Joost.

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


Re: How to make that eval could see its caller context

2010-05-31 Thread Joost
On May 31, 1:11 pm, Michael Jaaka michael.ja...@googlemail.com
wrote:
 Well, this is just an example.
 I need to refer to global vars from eval.

You can do that already:

user (def bla foo bar)

#'user/bla
user bla
foo bar
user (eval 'bla)
foo bar
user

It's just not a good idea.

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


Re: How to make that eval could see its caller context

2010-05-31 Thread Michael Jaaka
Hmmm, I have just missed on thing.
The problems comes when evaluation is in another thread.


(defn sleep[n] (Thread/sleep n))
(future
(eval (load-string ((fn[] (sleep 100) (println \wowo\)) )) ))



The solution is:


(defn sleep[n] (Thread/sleep n))
(let [a (get-thread-bindings) ]
(future
(with-bindings a
(eval (load-string ((fn[] (sleep 100) (println \wowo\)) )) 


I will try it on my code. Thanks anyway!

-- 
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: Datatype Usage Examples

2010-05-31 Thread Sina K. Heshmati
Meikel Brandmeyer m...@kotka.de said:
 On May 31, 10:58 am, Sina K. Heshmati s...@khakbaz.com wrote:
 
 foo.datatype-01 = (reset! state 13)
   ^^^
 
 Again: of course you can! You are in the same namespace! In Clojure
 the unit is a namespace and not a type. If you want this level
 privateness you have to use one namespace per type. However this is
 not really the Clojure Way.

Here's my concern:

- My program (A) is running.
- B is running on the same VM.
- B accesses the state of A.
- B alters the state of A in an inconsistent way e.g. whenever the internal 
state x changes, the internal state y also has to change accordingly, but B 
only changes x.
- A is screwed.

The author of Clojure calls encapsulation a folly but I don't understand why 
(?) How can we avoid situations like the one explained above?

I came up with the following, which does what I want by relying on the lexical 
scope of functions. This is OK but the only problem is the fact that I have to 
hardcode function calls for each type method.

(defprotocol prot-a
  (op-a [self x y]))

(let [state (atom 10)]
  (defn op-a
[self x y]
(+ x y (.member self) @state)))

(deftype t-a [member]
  prot-a
  (op-a [self x y]
(op-a self x y)))

(def t-a-1 (t-a. 5))

Is there a way to pass the function itself rather than making a new function 
that calls the exact same function with the same arguments?

Kind regards,
SinDoc

-- 
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: Datatype Usage Examples

2010-05-31 Thread Meikel Brandmeyer
Hi,

On May 31, 1:46 pm, Sina K. Heshmati s...@khakbaz.com wrote:

 Here's my concern:

 - My program (A) is running.
 - B is running on the same VM.
 - B accesses the state of A.
 - B alters the state of A in an inconsistent way
   e.g. whenever the internal state x changes, the
   internal state y also has to change accordingly,
   but B only changes x.
 - A is screwed.

A is namespace my.ns.a. There you define a private var: (def
^{:private true} state (atom 0)). B is namespace my.ns.b. B cannot
change state in A.

user= (ns my.ns.a)
nil
my.ns.a= (def ^{:private true} state (atom 0))
#'my.ns.a/state
my.ns.a= (ns my.ns.b)
nil
my.ns.b= (reset! my.ns.a/state :messed-up-your-state-harharhar)
java.lang.IllegalStateException: var: my.ns.a/state is not public
(NO_SOURCE_FILE:4)

From a philosophical point of view:
Either you develop an application and
  you are in charge of B. = You are in control: don't do it.
  you are not in charge of B. = B is obviously a crappy library which
you should not use in project.

You develop a library: A. Why bother? Since your library is well
documented it clearly defines the contract. Why care for people who
are too lazy to read?

 Is there a way to pass the function itself rather
 than making a new function that calls the exact
 same function with the same arguments?

(let [state (atom 0)]
  (extend t-a
prot-a
{:op-a (fn [this x y] (+ (.member this) x y @state))}))

Sincerely
Meikel

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


Modify clojure startup behavior

2010-05-31 Thread MHOOO
I'd like to have clojure *not* `(load x)` where x is at least:
clojure.zip, clojure.xml, clojure.set
when starting clojure up. I didn't really find any place in the
clojure code where I could do that except remove the entire subsystem
from the ant build.xml.
Anyone knows how to solve this? Is there some file which is
responsible for initializing 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


Re: Datatype Usage Examples

2010-05-31 Thread Sina K. Heshmati
Problem solved, see below.

Meikel Brandmeyer wrote:
 On May 31, 1:46 pm, Sina K. Heshmati s...@khakbaz.com wrote:
 
 Here's my concern:

 - My program (A) is running.
 - B is running on the same VM.
 - B accesses the state of A.
 - B alters the state of A in an inconsistent way
   e.g. whenever the internal state x changes, the
   internal state y also has to change accordingly,
   but B only changes x.
 - A is screwed.
 
 A is namespace my.ns.a. There you define a private var: (def
 ^{:private true} state (atom 0)). B is namespace my.ns.b. B cannot
 change state in A.
 
 user= (ns my.ns.a)
 nil
 my.ns.a= (def ^{:private true} state (atom 0))
 #'my.ns.a/state
 my.ns.a= (ns my.ns.b)
 nil
 my.ns.b= (reset! my.ns.a/state :messed-up-your-state-harharhar)
 java.lang.IllegalStateException: var: my.ns.a/state is not public
 (NO_SOURCE_FILE:4)
 
 From a philosophical point of view:
 Either you develop an application and
   you are in charge of B. = You are in control: don't do it.
   you are not in charge of B. = B is obviously a crappy library which
 you should not use in project.
 
 You develop a library: A. Why bother? Since your library is well
 documented it clearly defines the contract. Why care for people who
 are too lazy to read?

True but my main concern is security of a running application. It could very 
well be that B is just a bunch of interactions, in which case B can enter A's 
namespace.

I still haven't tried to use reflection to see if I can still access the state. 
In case a program can use metaprogramming to access private fields of an 
abstraction, no matter what the programmer does, then my concerns are not 
relevant.

 Is there a way to pass the function itself rather
 than making a new function that calls the exact
 same function with the same arguments?
 
 (let [state (atom 0)]
   (extend t-a
 prot-a
 {:op-a (fn [this x y] (+ (.member this) x y @state))}))

Thanks a bunch, Meikel.

Problem solved. Please see:
http://github.com/sindoc/algorithms/blob/master/src/main/clojure/whiteboard/y2010/hide-adt-state/datatype-and-closure-01.clj

Kind regards,
SinDoc

-- 
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: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-31 Thread abhi
+1 for swing

On Thu, May 27, 2010 at 8:48 PM, Luke VanderHart
luke.vanderh...@gmail.com wrote:
 My side project is a fairly complex GUI application written in
 Clojure. Recently, I've become irritated with using Java interop for
 everything. It's not that Clojure doesn't have nice java interop - it
 does. It's just that when interacting with a GUI framework, which is a
 large part of my app, I have to be back in mutable object-oriented
 land, worrying about class hierarchies, mutable state, locks, etc.
 Yucky.

 So, with a perhaps dangerous lack of sanity and without any guarantee
 of success, I've decided to try my hand at writing an idiomatic
 Clojure GUI library. If I have success (which I doubt) I will of
 course make it available as open source.

 I intend for it to be mostly declarative, with a nice DSL for defining
 GUI elements. Each component will also implement map, and use one of
 Clojure's reference types as an interface for inspecting / updating
 its state. I may also implement some aspects of Functional Reactive
 Programming wherever it's convenient to do so.

 What you all must help me decide is what GUI framework to use as the
 underpinnings of it. It's genuinely hard to decide. I have at least
 some experience with all of them, so I have no strong preference, but
 I'd like to get your input. I did consider trying to make it abstract
 enough that you could plug in *any* of them under the hood, but
 there's enough differences between the frameworks that that would get
 very ugly very fast.

 Possibilities are:

 AWT
 Pros: native widgets, bundled with Java, low-level
 Cons: few widgets, considered somewhat obselete

 Swing
 Pros: bundled with Java, good widget selection
 Cons: non-native widgets

 SWT
 Pros: native widgets, widely used
 Cons: requires platform-specific libs

 QT Jambi
 Pros: native widgets, huge widget selection, highly-regarded framework
 Cons: requires platform-specific libs, writing custom widgets is
 hairy, momentum and support seem to be lagging since Nokia dropped
 official support.

 Remember, the actual API won't matter - that will be completely
 abstracted away. So try to focus on the framework's look and feel.
 Also let me know if I've missed any of the framework's key
 characteristics.

 Thanks!

 -Luke















 --
 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: special forms and let binding

2010-05-31 Thread Аркадий Рост
In fact, keywords are not symbols. So thats why you were wrong.

You can read about in on the page http://clojure.org/lisps

-- 
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: Datatype Usage Examples

2010-05-31 Thread Meikel Brandmeyer
Hi,

On May 31, 3:15 pm, Sina K. Heshmati s...@khakbaz.com wrote:

 True but my main concern is security of a running application.
 It could very well be that B is just a bunch of interactions,
 in which case B can enter A's namespace.

??? I'm not sure I understand. How can B enter the namespace
of A? If you mean you have a Repl and someone arbitrary can
enter commands there as she likes... You can always mess up
everything.

 I still haven't tried to use reflection to see if I can still
 access the state. In case a program can use metaprogramming
 to access private fields of an abstraction, no matter what the
 programmer does, then my concerns are not relevant.

To be honest: I don't see the problem. You talk about a very
fuzzy the user might do something. Do you have a particular
scenario in mind?

 Problem solved.

Just some minor remarks: you can move the extend outside the
let and the declare is not necessary. defprotocol will take
care of that for you.

Sincerely
Meikel

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


Re: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-31 Thread faenvie
in case, you want to abstract over swing ...

there is this guy from germany: Karsten Lentzsch. he is author of
http://www.jgoodies.com/ and has incredible knowledge about swing
and esp. in abstracting over swing.

He knows all the strongs and weaknesses of swing and beeing involved
in http://www.jgoodies.com/articles/jsr296_de.pdf he tried to move
things
forward but was not very lucky doing so - according to his
presentation at
the wjax munich in Oktober last year.

maybe Karsten could be asked  for his expertise ...

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


[ANN]: Google Chrome extension for TryClojure (try-clojure.org)

2010-05-31 Thread sergey-miryanov
Hi all,

 I made a little extension for google chrome. It allows to start try-
clojure REPL via clicking on toolbar button. Also it grabs selected
text and evaluates it in REPL.

Feel free to comment, report bugs and suggestions.


/Sergey

-- 
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: Multithreading didn't make my program as much faster as I expected...

2010-05-31 Thread Paul Moore
On 31 May 2010 06:12, Zak Wilson zak.wil...@gmail.com wrote:
 The trouble with pmap is that it only works well with a slow function
 and a short sequence. In trivial tests, it seems to be best if the
 sequence has as many elements as you do cores.

 I've been experimenting with things that are like pmap, but work
 better in situations that I care about. I'm having trouble getting
 full performance out of a quad-core machine, but dual-core is working
 pretty well so far. Here's some discussion with a link to sample code:
 http://groups.google.com/group/clojure/browse_thread/thread/963cdb76f0c3c178

 And here's my personal utility file containing mostly re-
 implementations of things I didn't know where to find. The zpmap
 function is an eager parallel map that works well on large vectors and
 maps with a fairly fast function:
 http://github.com/zakwilson/zutil-clj/blob/master/util.clj

Interesting! Reducing the number of parallel threads in my test case
from 10 to 2 improved the speed of the test from 12 seconds to 10,
which is about as good as can be expected. And it immediately steps
back up to 12 seconds when I use 3 threads.

So for CPU intensive tasks, it seems that having precisely the same
number of threads as CPUs gives the best performance. It looks like
Java schedules 1 thread per CPU, until it can't, and at that point
scheduling overhead kicks in (costing something like 30% performance).

How did you arrive at the number of CPUs + 2 approach in zpmap? I'd
have thought that the +2 would hurt performance as it did in my case.

So even when Clojure makes threading as easy as possible, it's still
complicated in subtle ways. Ah, well :-)

Thanks for the help.
Paul.

-- 
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 script with shebangoid on windows

2010-05-31 Thread Paul Moore
On 31 May 2010 07:48, alux alu...@googlemail.com wrote:
 Hello Glen, good hint. Problem and solution reproduced ;-)

Yes, it looks like Clojure's (comment ...) form requires the contents
of the comment to be syntactically correct Clojure forms. As Glen
says, forward slashes seem to work - although personally, I dislike
being forced to use forward slashes on Windows :-(

Is there a multi-line comment form in Clojure that can contain arbitrary text?
Paul.

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


java.lang.Boolean cannot be cast to clojure.lang.IFn

2010-05-31 Thread garyk
Hi,
I've started learn Clojure. While I am writing some functions I was
getting the java.lang.Boolean cannot be cast to clojure.lang.IFn. I
was wondering if somebody could help me to move on:

; for testing
(def sudoku ( sorted-map '[1 1] '(98) '[1 2] '(123) '[2 1] '(56789)
'[2 2] '(456)))
(def vall 4)
(def poss (vector [1 1] [1 2]))


(defn valueIn [map value positions]
  (loop [start (first positions) end (rest positions) cont false]
(if (or (true? cont) (nil? start))
  cont
  (recur (cont (contains? (get map start) value)) (start (first
end)) (end (rest end))

The call= (valueIn(sudoku vall poss) gives me the above error.

Thank you,
-- Gary

-- 
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: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-31 Thread Brian Troutwine
+1 swing. Even if the resulting applications are as ugly as sin, a
working, idiomatic implementation gives us a reference point from
which to dream up better futures.

On Sun, May 30, 2010 at 10:38 PM, Antony Blakey antony.bla...@gmail.com wrote:

 On 31/05/2010, at 2:27 PM, James Cunningham wrote:



 On May 30, 9:23 pm, Antony Blakey antony.bla...@gmail.com wrote:
 I care about Mac and Windows primarily, and building software that will 
 sell (not dev tools) requires good native look and feel.

 Do you have a single example of an SWT app that has a decent feel on
 OS X? I've spent a fair amount of time with Eclipse lately, and---
 frankly---it feels about as native as an Alabaman in Nice. No native
 toolbar, no native tabs, slower and uglier than either Netbeans or
 Intellij. My only other experience with an SWT app was entirely
 negative from a performance and look-and-feel perspective (Vuze).

 Vuze looks OK to me in the 5 minutes I've just spent. In any case, my opinion 
 comes from doing parallel GUI development in IB and SWT to see if I could use 
 Clojure/SWT rather than MacRuby (XCode/IB). I'm not using the RCP which 
 imprints it's own not-really-OSX flavour in spite of the widgets.

 You have to do more than just use SWT to get a Mac application to feel right, 
 and one's GUI layout code needs to be parametric and rules based, rather than 
 just swapping the LF. That said, it's still easier than writing three UIs.

 Antony Blakey
 -
 CTO, Linkuistics Pty Ltd
 Ph: 0438 840 787

 The intuitive mind is a sacred gift and the rational mind is a faithful 
 servant. We have created a society that honours the servant and has forgotten 
 the gift.
  -- Albert Einstein


 --
 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: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-31 Thread laseray
Let the best decider of a GUI toolkit be based on pragmatism and
design philosophy.

To that end Swing wins.

Clojure runs on JVM and takes advantage of anything Java that it does
not provide for in a Lispy way.
Swing is just another one of those things automatically there, which
can have a nice layer to make it more useful, interesting.

Clojure does not include any extra libraries, except ASM, to operate.
Won't need any extra ones by using a Swing-based layer.

Clojure is completely cross-platform with supported OS for Java. A
Swing layer will be also.

Clojure can already create simple GUIs with Swing in a few lines of
code. It can only get better with a dedicated layer.

Swing is already a good selling point for Clojure. It actually is
promoting Clojure to have read Swing support intrinsically.

You cannot say these things about any other toolkit at this time.

I am willing to do some work on the Swing layer, if it is wanted. If
others want to work on SWT, Tk, etc. they can do that.
That's what it comes down to, where the effort is put.

I will step up to put some of mine behind the Swing-based one, anybody
else?

Voting and debating points are okay, but results are better. Swing is
already a result, a layer is just furthering it.

-- 
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: (apply interleave [[1 2]])

2010-05-31 Thread Paul Hobbs
Makes sense.
--
Paul Hobbs


On Sat, May 29, 2010 at 11:51 PM, Eugen Dück eu...@dueck.org wrote:

 Paul,

 I already gave a minimal example of the code it makes simpler, i.e.
 work in the first place:

 (apply interleave some-colls)

 I ran into this a couple of times, and wrote my own variant of
 interleave that handles the one-coll case. I'd rather see this case
 handled by interleave.

 How often do you do:

 (+ 5)

 or

 (* 3)

 ? But you might have used something like

 (apply + coll)

 or

 (reduce + coll)

 and under certain circumstances your coll might have had only one
 element. Still + works just fine and returns a value that makes sense
 (it even does if you call it with no argument). I'm basically asking
 to get the same case that clojure handles for a lot of other functions
 added to interleave.

 Eugen

 On May 29, 7:07 pm, Paul Hobbs paul_ho...@hmc.edu wrote:
  What code would this make simpler?  Are you constantly having to check
 this

   (apply interleave some-colls)

  special case?  If not, I don't see a reason to include it.
  --
  Paul Hobbs
 
  On Sat, May 29, 2010 at 1:32 AM, Eugen Dück eu...@dueck.org wrote:
   When I do
 
   (apply interleave some-colls)
 
   and some-colls is a sequence/collection of only one sequence/
   collection, it will throw:
 
   user= (apply interleave [[1 2]])
   java.lang.IllegalArgumentException: Wrong number of args passed to:
   core$interleave (NO_SOURCE_FILE:0)
 
   (Of course I don't need the apply to cause that exception, but calling
   interleave directly with just one parameter doesn't make any sense.
   But in the case you use apply, having only one sequence in a sequence
   is a possible corner case that can arise at run time)
 
   In order to make interleave more general, I'd like to add a one param
   overload to interleave like
 
   (defn interleave
Returns a lazy seq of the first item in each coll, then the second
   etc.
([c] (seq c))
...
 
   or even just
 
   (defn interleave
([c] c)
 
   but that would break the contract of interleave, in that it returns
   whatever you pass in, which might not be a sequence, as is the case in
   my example.
 
   Any thoughts on this?
 
   Eugen
 
   --
   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.comclojure%2bunsubscr...@googlegroups.com
 clojure%2bunsubscr...@googlegroups.comclojure%252bunsubscr...@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.comclojure%2bunsubscr...@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: Modify clojure startup behavior

2010-05-31 Thread Remco van 't Veer
On 2010/05/31 14:25, MHOOO wrote:

 I'd like to have clojure *not* `(load x)` where x is at least:
 clojure.zip, clojure.xml, clojure.set
 when starting clojure up. I didn't really find any place in the
 clojure code where I could do that except remove the entire subsystem
 from the ant build.xml.
 Anyone knows how to solve this? Is there some file which is
 responsible for initializing clojure?

It isn't a very pretty way but you can simply remove the load statements
from RT.java around line 415.  That works fine.  If you really need any
of them later, you can still use/require/load them.

-- 
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: special form vs. macro

2010-05-31 Thread Patrick Stein
Maybe Clojure uses the term special form differently than Common
Lisp does, but here's how to think of special form in the Common
Lisp sense.

A form that is *NOT* a special form like (F A B C D ...) will either
evaluate:

1. (SYMBOL-FUNCTION F), then A, B, C, D, ... in order from left-to-
right, OR
2. A, B, C, D, ... in order from left-to-right then (SYMBOL-FUNCTION
F)

And, cannot change the lexical environment (add or remove symbols in
the environment).

It is up to the implementation whether (SYMBOL-FUNCTION F) gets
evaluated first or last, but A, B, C, D, ... get evaluated from let to
right in order before F is invoked.

Any form that does not ALWAYS obey that is a special form.

Examples:

(+ 3 5 (+ 6 7) ii), the form 3 is evaluated, then 5, then (+ 6 7),
then ii, then all of these are passed to (SYMBOL-FUNCTION +) to
execute.  This IS NOT a special form.

(IF A B C) does not evaluate both B and C.  Thus, it IS a special
form.

The following IS NOT a special form (as long as XX and YY aren't
dynamic variables that we're overriding but rather just local
variables here like it looks) because it always evaluates A and B in
the expected order:
(DEFMACRO WEIRD (A B)
   `(LET ((XX ,A))
  (LET ((YY ,B))
  (DO-SOMETHING (+ XX YY) (- XX YY)

(WEIRD (+ 6 7) ii)


The following IS a special form because it does not evaluate A and B
in the expected order:
(DEFMACRO WEIRD-SPECIAL (A B)
   `(LET ((YY ,B))
  (LET ((XX ,A))
  (DO-SOMETHING (+ XX YY) (- XX YY)

(WEIRD-SPECIAL (+ 6 7) ii)

The following IS also a special form since it doesn't always evaluate
A and B in the expected order:
(DEFMACRO WEIRD-MAY-BE-SPECIAL (SPECIAL A B)
   `(IF ,SPECIAL
   (LET ((XX ,A))
 (LET ((YY ,B))
(DO-SOMETHING (+ XX YY) (- XX YY
   (LET ((YY ,B))
 (LET ((XX ,A))
(DO-SOMETHING (+ XX YY) (- XX YY)

(WEIRD-MAY-BE-SPECIAL (ZEROP (RANDOM 2)) (+ 6 7) ii)

The term special form (at least in Common Lisp) has nothing to do
with whether it is built-in or user-defined.  It has to do with
whether or not all of its components are evaluated in the expected
order.

ttyl,
Patrick

-- 
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: special form vs. macro

2010-05-31 Thread Quzanti
That was interesting.

One more Q.

What determines whether special forms can be used in functions eg you
can't def a variable in a fn.

Is it there some rule or is it special form specific depending on
(a) the intended use of the special form
(b) the mechanics of getting the compiler to use the special form

On May 31, 9:48 am, Jarkko Oranen chous...@gmail.com wrote:
 On May 31, 10:35 am, alux alu...@googlemail.com wrote:

  [  ] A special form is what can be implemented by a macro.

 That depends. My understanding is that a special form is something
 that is fundamental to the language, that the evaluator handles as a
 special case. That is, they need to be implemented in the compiler/
 interpreter itself. However, in practice you can't really tell the
 difference between a macro and a special form, and in fact some
 Clojure special forms are implemented as macros (on top of a real
 special form that is an implementation detail)



  [  ] Every macro gives a special form.

 Not really. All macros have the same evaluation semantics (macro
 expansion).

  [  ] Only a macro that doesn't evaluate some of its arguments gives a
  special form.

 I don't think evaluation of arguments matters.



  [  ] A special form is always built in, and cannot be implemented in
  the language itself.

 That depends on your point of view, but in general, yes.



  [  ] Special forms are exactly the things that can be called, but dont
  evaluate all of their arguments. (Macros and build-ins, at least for
  eager languages.)

 Special forms are special because the evaluator has separate
 evaluation rules for each of them. Other than that, they are merely
 another kind of operator (the others being macros and functions)



  [  ] The concept of special form doesnt have anything to do with
  eagerness or lazyness.

 This is correct.

-- 
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: special form vs. macro

2010-05-31 Thread Joost

On May 31, 4:35 pm, Quzanti quza...@googlemail.com wrote:
 That was interesting.

 One more Q.

 What determines whether special forms can be used in functions eg you
 can't def a variable in a fn.

You can:

user (defn fun [v] (def my-v v))
user (fun 'a)
user my-v
a
user (fun 'b)
user my-v
b

I'm not aware of any special form that can't be used inside a
function.
But I haven't looked for them either.

 Is it there some rule or is it special form specific depending on
 (a) the intended use of the special form
 (b) the mechanics of getting the compiler to use the special form

First you'd have to find such special forms.

-- 
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: java.lang.Boolean cannot be cast to clojure.lang.IFn

2010-05-31 Thread Joost
On May 31, 2:11 pm, garyk gkhomin...@gmail.com wrote:
 Hi,
 I've started learn Clojure. While I am writing some functions I was
 getting the java.lang.Boolean cannot be cast to clojure.lang.IFn. I
 was wondering if somebody could help me to move on:

 ; for testing
 (def sudoku ( sorted-map '[1 1] '(98) '[1 2] '(123) '[2 1] '(56789)
 '[2 2] '(456)))
 (def vall 4)
 (def poss (vector [1 1] [1 2]))

 (defn valueIn [map value positions]
   (loop [start (first positions) end (rest positions) cont false]
     (if (or (true? cont) (nil? start))
       cont
       (recur (cont (contains? (get map start) value)) (start (first
 end)) (end (rest end))

recur takes positional arguments, not (key value) pairs (which
aren't pairs, but function calls).
You want *something* like

 (recur (first end)  (rest end)  (contains? (get map start) value))

but I can't really make heads or tails out of your code. Note that
'(56789) is a list of ONE number, while it looks like you're expecting
it to be a list of digits - that would be '(5 6 7 8  9)

-- 
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: java.lang.Boolean cannot be cast to clojure.lang.IFn

2010-05-31 Thread Joost
Oh, and you code throws clojure.lang.PersistentVector cannot be cast
to java.lang.Number
  [Thrown class java.lang.ClassCastException] for me.

-- 
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: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-31 Thread lprefontaine
We are willing to put some time into this at our end.
We are in the process of replacing our Java desktop apps by Clojure apps.
Removing Java code is a mid-term goal that we want to keep in our scope
as we move on.

Anything to reduce code size is a welcomed.

How and when do we start this ?

Luc P.

laseray lase...@gmail.com wrote ..
 Let the best decider of a GUI toolkit be based on pragmatism and
 design philosophy.
 
 To that end Swing wins.
 
 Clojure runs on JVM and takes advantage of anything Java that it does
 not provide for in a Lispy way.
 Swing is just another one of those things automatically there, which
 can have a nice layer to make it more useful, interesting.
 
 Clojure does not include any extra libraries, except ASM, to operate.
 Won't need any extra ones by using a Swing-based layer.
 
 Clojure is completely cross-platform with supported OS for Java. A
 Swing layer will be also.
 
 Clojure can already create simple GUIs with Swing in a few lines of
 code. It can only get better with a dedicated layer.
 
 Swing is already a good selling point for Clojure. It actually is
 promoting Clojure to have read Swing support intrinsically.
 
 You cannot say these things about any other toolkit at this time.
 
 I am willing to do some work on the Swing layer, if it is wanted. If
 others want to work on SWT, Tk, etc. they can do that.
 That's what it comes down to, where the effort is put.
 
 I will step up to put some of mine behind the Swing-based one, anybody
 else?
 
 Voting and debating points are okay, but results are better. Swing is
 already a result, a layer is just furthering it.
 
 -- 
 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: java.lang.Boolean cannot be cast to clojure.lang.IFn

2010-05-31 Thread B Smith-Mannschott
On Mon, May 31, 2010 at 14:11, garyk gkhomin...@gmail.com wrote:
 Hi,
 I've started learn Clojure. While I am writing some functions I was
 getting the java.lang.Boolean cannot be cast to clojure.lang.IFn. I
 was wondering if somebody could help me to move on:

 ; for testing
 (def sudoku ( sorted-map '[1 1] '(98) '[1 2] '(123) '[2 1] '(56789)
 '[2 2] '(456)))
 (def vall 4)
 (def poss (vector [1 1] [1 2]))


 (defn valueIn [map value positions]
  (loop [start (first positions) end (rest positions) cont false]
    (if (or (true? cont) (nil? start))
      cont
      (recur (cont (contains? (get map start) value)) (start (first
 end)) (end (rest end))

Your (recur ...) is completely mixed up.  The specific error you are
seeing is because of the subexpression:

(cont (contains? ...)) which attempts to apply cont as a function to
the result of the call to (contains? ...). cont isn't a function, it's
a boolean value (you gave it the value false at the start of the
loop).

 The call= (valueIn(sudoku vall poss) gives me the above error.

 Thank you,
 -- Gary

 --
 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: Datatype Usage Examples

2010-05-31 Thread Sina K. Heshmati
Meikel Brandmeyer wrote:
 On May 31, 3:15 pm, Sina K. Heshmati s...@khakbaz.com wrote:
 
 True but my main concern is security of a running application.
 It could very well be that B is just a bunch of interactions,
 in which case B can enter A's namespace.
 
 ??? I'm not sure I understand. How can B enter the namespace
 of A? If you mean you have a Repl and someone arbitrary can
 enter commands there as she likes... You can always mess up
 everything.
 
 I still haven't tried to use reflection to see if I can still
 access the state. In case a program can use metaprogramming
 to access private fields of an abstraction, no matter what the
 programmer does, then my concerns are not relevant.
 
 To be honest: I don't see the problem. You talk about a very
 fuzzy the user might do something. Do you have a particular
 scenario in mind?

You're right. It's rather a contract problem as you said than a security 
concern because no matter what we do, people can use reflection to mess things 
up anyway.

I'm likely to drop the whole idea of encapsulating the state in a closure and 
rely on private annotations.

Thanks Meikel for bearing with me :)

 Problem solved.
 
 Just some minor remarks: you can move the extend outside the
 let and the declare is not necessary. defprotocol will take
 care of that for you.

Nice. That's much better.

I'd like to thank Meikel, Krukow, and Adrian for participating in this 
discussion.

Kind regards,
SinDoc

-- 
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: Multithreading didn't make my program as much faster as I expected...

2010-05-31 Thread Zak Wilson
Number of CPUs + 2 is what pmap uses, and I assumed the idea was to
keep all the CPUs busy in the event that one finishes before the
others. I wrote it before I did testing with npmap. Since reading your
last post, I did a bit of testing with modified versions of zpmap and
found that it isn't making much difference on a quad-core machine. It
might be a few ms faster on a 3.5s call, but it's so close that it's
probably within the margin of error.

It may turn out to be a better approach to rewrite pmap instead of
wrapping it. I'm wondering if the attempt to make it both semi-lazy
and parallel isn't optimal for speed.

-- 
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: special form vs. macro

2010-05-31 Thread Quzanti
Are you sure that always works?

I think I am misunderstanding Halloway's Taxonomy of Macro's chapter

defstruct is written as a macro and Stuart then comments

This macro looks so simple that you may be tempted to try to write it
as a function. You won't be able to because def is a special form. You
must generate def at macro time; you cannot make 'dynamic' calls to
def at runtime

On May 31, 4:05 pm, Joost jo...@zeekat.nl wrote:
 On May 31, 4:35 pm, Quzanti quza...@googlemail.com wrote:

  That was interesting.

  One more Q.

  What determines whether special forms can be used in functions eg you
  can't def a variable in a fn.

 You can:

 user (defn fun [v] (def my-v v))
 user (fun 'a)
 user my-v
 a
 user (fun 'b)
 user my-v
 b

 I'm not aware of any special form that can't be used inside a
 function.
 But I haven't looked for them either.

  Is it there some rule or is it special form specific depending on
  (a) the intended use of the special form
  (b) the mechanics of getting the compiler to use the special form

 First you'd have to find such special forms.

-- 
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: special form vs. macro

2010-05-31 Thread Angel Java Lopez
Hi people!

Nice explanation, about the difference of special form in Clojure, vs
other Lisp.

I remember (Queinnec Lisp?):

lambda: to make normal functions
mlambda: to make macros (something that produce a form, and then, evaluate
that result)
flambda: spread, non evaluation of parameters
nlambda: non-spread (all arguments in one variable), non evaluation of
parameters.

Usually, when I wrote a Lisp interpreter, I implement the above words.

AFAIK, Clojure doesn't have any way to build a new special form, except via
macros. Why? It was a design decision? motivated by Java compilation?

Angel Java Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez


On Mon, May 31, 2010 at 11:06 AM, Patrick Stein p...@nklein.com wrote:

 Maybe Clojure uses the term special form differently than Common
 Lisp does, but here's how to think of special form in the Common
 Lisp sense.

 A form that is *NOT* a special form like (F A B C D ...) will either
 evaluate:

 1. (SYMBOL-FUNCTION F), then A, B, C, D, ... in order from left-to-
 right, OR
 2. A, B, C, D, ... in order from left-to-right then (SYMBOL-FUNCTION
 F)

 And, cannot change the lexical environment (add or remove symbols in
 the environment).

 It is up to the implementation whether (SYMBOL-FUNCTION F) gets
 evaluated first or last, but A, B, C, D, ... get evaluated from let to
 right in order before F is invoked.

 Any form that does not ALWAYS obey that is a special form.

 Examples:

 (+ 3 5 (+ 6 7) ii), the form 3 is evaluated, then 5, then (+ 6 7),
 then ii, then all of these are passed to (SYMBOL-FUNCTION +) to
 execute.  This IS NOT a special form.

 (IF A B C) does not evaluate both B and C.  Thus, it IS a special
 form.

 The following IS NOT a special form (as long as XX and YY aren't
 dynamic variables that we're overriding but rather just local
 variables here like it looks) because it always evaluates A and B in
 the expected order:
 (DEFMACRO WEIRD (A B)
   `(LET ((XX ,A))
  (LET ((YY ,B))
  (DO-SOMETHING (+ XX YY) (- XX YY)

 (WEIRD (+ 6 7) ii)


 The following IS a special form because it does not evaluate A and B
 in the expected order:
 (DEFMACRO WEIRD-SPECIAL (A B)
   `(LET ((YY ,B))
  (LET ((XX ,A))
  (DO-SOMETHING (+ XX YY) (- XX YY)

 (WEIRD-SPECIAL (+ 6 7) ii)

 The following IS also a special form since it doesn't always evaluate
 A and B in the expected order:
 (DEFMACRO WEIRD-MAY-BE-SPECIAL (SPECIAL A B)
   `(IF ,SPECIAL
   (LET ((XX ,A))
 (LET ((YY ,B))
(DO-SOMETHING (+ XX YY) (- XX YY
   (LET ((YY ,B))
 (LET ((XX ,A))
(DO-SOMETHING (+ XX YY) (- XX YY)

 (WEIRD-MAY-BE-SPECIAL (ZEROP (RANDOM 2)) (+ 6 7) ii)

 The term special form (at least in Common Lisp) has nothing to do
 with whether it is built-in or user-defined.  It has to do with
 whether or not all of its components are evaluated in the expected
 order.

 ttyl,
 Patrick

 --
 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.comclojure%2bunsubscr...@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: Newbie question about vector performance

2010-05-31 Thread David Nolen
On Fri, May 28, 2010 at 12:20 PM, Rubén Béjar ruben.be...@gmail.com wrote:

  Hi again,

 I have tried a few more things:

 I have done the same in Java but using an array
 of Integers, instead of an array of ints. It just takes
 78 ms. (more than 16, still far less than 4 secs).

 I have also tried with an update function which just returns a
 fixed 1. It still takes some 400 ms. to update de
 data vector of the CA. This is similar to the time
 it is giving me to create a vector of 1's with this function:
 (time (vec (repeat 25 1))).

 I was not expecting Clojure vectors so much slower than
 Java arrays. Is that comparison so unfair? Next thing
 I am trying is using Java Vectors in my Java
 implementation...

Rubén


I looked into your code and came up with this: http://gist.github.com/420036

On my machine 500x500 takes about 60-70ms. 2000x2000 takes about ~940ms.

Also, Clojure vectors aren't slow:

(defn vec-repeat [n x]
(loop [n n v (transient [])]
  (if (zero? n)
(persistent! v)
(recur (dec n) (conj! v x)

(vec-repeat 25 1)

Takes 4-7ms

(vec-repeat 250 1)

Takes 50-60ms

Transients aren't an advanced topic, they solve the problem of building up
large vectors in a memory/cpu efficient manner.

In very tight loops over primitive data:

1. Spending time accessing Clojure data structures can hurt you
2. Spending time creating temporary data structures can hurt you
3. Inline the most called bits.

Fast Clojure code that works with arrays need not look ugly (checkout amap
and areduce). Also macros can alleviate the tedious typing of type hints.

David

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

Re: Newbie question about vector performance

2010-05-31 Thread David Nolen
On Sun, May 30, 2010 at 3:49 PM, Rubén Béjar ruben.be...@gmail.com wrote:

 is not very precise with that short periods of time) and  in Clojure the
 2000x2000 CA
 is updated in 98 secs some times and up to 150 s. other times (the 500x500
 was 4 secs),


When numbers fluctuate like that I'm pretty sure you're hitting GC. Another
reason to use transients if you're going to use vectors to store a lot of
data.

David

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

Re: Datatype Usage Examples

2010-05-31 Thread Meikel Brandmeyer
Hi,

On Mon, May 31, 2010 at 07:34:24AM +0200, Sina K. Heshmati wrote:

  (defn make-module
[]
(let [state (atom 0)
  say-hello (fn [] (println Hello))
  public-op (fn [x y] (+ @state x y))]
  (fn [op]
(case op
  :hello  say-hello
  :public public-op
 
 Could you elaborate a bit please? Is there a reason why nested defns are 
 wrong?

I'm sorry. I missed this question.

def always introduces a global binding. It is unlike schemes define.
So invoking make-module twice basically overwrites the first defs
with the second ones.

Sincerely
Meikel

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


Re: special form vs. macro

2010-05-31 Thread Meikel Brandmeyer
Hi,

On Mon, May 31, 2010 at 10:21:14AM -0700, Quzanti wrote:

 Are you sure that always works?
 
 I think I am misunderstanding Halloway's Taxonomy of Macro's chapter
 
 defstruct is written as a macro and Stuart then comments
 
 This macro looks so simple that you may be tempted to try to write it
 as a function. You won't be able to because def is a special form. You
 must generate def at macro time; you cannot make 'dynamic' calls to
 def at runtime

It works sometimes. Of course you can redef a Var via function.

(defn foo [y] (def x y))
(foo 5)

However, you cannot define arbitrary Vars.

(defn bar [x y] (def x y))
(bar 'c 5)

This does *not* define Var named c. So can't really make 'dynamic'
calls to def at runtime. Just as Stuart writes.

Sincerely
Meikel

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


Re: special form vs. macro

2010-05-31 Thread Joost
On May 31, 7:54 pm, Meikel Brandmeyer m...@kotka.de wrote:
 It works sometimes. Of course you can redef a Var via function.

 (defn foo [y] (def x y))
 (foo 5)

 However, you cannot define arbitrary Vars.

 (defn bar [x y] (def x y))
 (bar 'c 5)

True, but that's more a question of the interface provided by def. The
real problem is that if you want to access the vars defined by that
function anywhere else, they need to be defined (if not initialized)
before you can compile the code. Meaning you either have to def those
vars somewhere else (outside of a function) or make sure the function
gets called at least once before any access is mentioned in the code.

After that, you can re-define the var in any way you like.


-- 
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: special forms and let binding

2010-05-31 Thread Ark. Rost
So I don't understand if there any way do it. I'm really curious about
it.

-- 
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: Rationals, and their size

2010-05-31 Thread ataggart


On May 31, 12:18 am, alux alu...@googlemail.com wrote:
 Ah, thank you - I still shy away from looking into Richs sources, but
 here it helps: Ratio doesn't have getter for numerator and denominator
 - they are just public ;-)

Ha! A blindspot due to writing idiomatic java for far too long.



 Being final thats okay of course.

 So. Whether this helps, I dont know too. I still dont have the lever,
 but now I have a point to place it at ;-)

 Regards, alux

 On 31 Mai, 04:10, ataggart alex.tagg...@gmail.com wrote:



  Ratio doesn't emit the numerator and 
  denominator:http://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lang...

  I'm not sure that would help solve your problem, even if it were
  available.  You either need to turn the ratio into a non-ratio (using
  float or double) or use unchecked math functions which are subject to
  truncation (e.g., unchecked-multiply).

  On May 30, 1:32 pm, alux alu...@googlemail.com wrote:

   Hello,

   I careless used rationals in a function, and, well, it took some
   minutes to understand why it was slowing down. (I did this formatting
   by (println (* 1.0 x)) when it started being unreadable - and forgot
   that).

   I still see rationals as very nice, but try to use them carefully now.
   What I would really like is a possibility to round to a numer of a
   certain size. Like, to an continued fraction of a certain size. But,
   there I need access to the length of numerator and denominator.

   Now the question - is there any way to access this (or to reach to
   goal of rounding to a rational), that is easier than using the
   BigIntegers myself?

   Thank you, alux

-- 
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: : Google Chrome extension for TryClojure (try-clojure.org)

2010-05-31 Thread sergey-miryanov
Missing link 
https://chrome.google.com/extensions/detail/lhmgejcdhmollecbianopflcfdaennle
;)

On 31 май, 16:04, sergey-miryanov sergey.mirya...@gmail.com wrote:
 Hi all,

  I made a little extension for google chrome. It allows to start try-
 clojure REPL via clicking on toolbar button. Also it grabs selected
 text and evaluates it in REPL.

 Feel free to comment, report bugs and suggestions.

 /Sergey

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


confused about getting started with compojure on google app engine

2010-05-31 Thread Zitterbewegung
I was wondering which tutorial I should use to get started with
compojure on google app engine. There seem to be a bunch of them but
they target old versions or slightly old versions. Which one should I
use?

-- 
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: (apply interleave [[1 2]])

2010-05-31 Thread Daniel Werner
On May 30, 12:51 am, Eugen Dück eu...@dueck.org wrote:
 How often do you do:
 (+ 5)
 or
 (* 3)

 ? But you might have used something like
 (apply + coll)
 or
 (reduce + coll)

 and under certain circumstances your coll might have had only one
 element.

This is a good line of reasoning. Let's add an example in quantitative
logic, in which corner cases aren't that obvious at first glance:

user= (every? pos? #{})
true

Clojure follows the mathematical definition here and concludes that
all members of the empty set are indeed positive :-)  This is a useful
behaviour since the programmer probably wanted to keep out non-
positive numbers, and the empty set satisfies this restriction. No
need to check for an empty collection beforehand.

-- 
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: (apply interleave [[1 2]])

2010-05-31 Thread Daniel Werner
On May 31, 10:07 pm, Daniel Werner daniel.d.wer...@googlemail.com
wrote:
 quantitative logic

That should have been quantification logic.

-- 
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: Rationals, and their size

2010-05-31 Thread alux
Yep, know that, been there ;-))

On 31 Mai, 21:39, ataggart alex.tagg...@gmail.com wrote:
 On May 31, 12:18 am, alux alu...@googlemail.com wrote:

  Ah, thank you - I still shy away from looking into Richs sources, but
  here it helps: Ratio doesn't have getter for numerator and denominator
  - they are just public ;-)

 Ha! A blindspot due to writing idiomatic java for far too long.



  Being final thats okay of course.

  So. Whether this helps, I dont know too. I still dont have the lever,
  but now I have a point to place it at ;-)

  Regards, alux

  On 31 Mai, 04:10, ataggart alex.tagg...@gmail.com wrote:

   Ratio doesn't emit the numerator and 
   denominator:http://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lang...

   I'm not sure that would help solve your problem, even if it were
   available.  You either need to turn the ratio into a non-ratio (using
   float or double) or use unchecked math functions which are subject to
   truncation (e.g., unchecked-multiply).

   On May 30, 1:32 pm, alux alu...@googlemail.com wrote:

Hello,

I careless used rationals in a function, and, well, it took some
minutes to understand why it was slowing down. (I did this formatting
by (println (* 1.0 x)) when it started being unreadable - and forgot
that).

I still see rationals as very nice, but try to use them carefully now.
What I would really like is a possibility to round to a numer of a
certain size. Like, to an continued fraction of a certain size. But,
there I need access to the length of numerator and denominator.

Now the question - is there any way to access this (or to reach to
goal of rounding to a rational), that is easier than using the
BigIntegers myself?

Thank you, alux

-- 
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: special forms and let binding

2010-05-31 Thread alux
Hi Аркадий,

I started another thread about the difference between special form and
macros today - and got told that it is not possible to overwrite a
special form.

Regards, alux

On 31 Mai, 21:15, Ark. Rost arkr...@gmail.com wrote:
 So I don't understand if there any way do it. I'm really curious about
 it.

-- 
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: Datatype Usage Examples

2010-05-31 Thread Sina K. Heshmati
Hi Meikel,

Meikel Brandmeyer wrote:

 On Mon, May 31, 2010 at 07:34:24AM +0200, Sina K. Heshmati wrote:
 
  (defn make-module
[]
(let [state (atom 0)
  say-hello (fn [] (println Hello))
  public-op (fn [x y] (+ @state x y))]
  (fn [op]
(case op
  :hello  say-hello
  :public public-op

 Could you elaborate a bit please? Is there a reason why nested defns are 
 wrong?
 
 I'm sorry. I missed this question.

Thanks for the follow-up.

 def always introduces a global binding. It is unlike schemes define.
 So invoking make-module twice basically overwrites the first defs
 with the second ones.

I see now. I used to think of them as defines in Scheme but I started to notice 
this when I saw them survive closures.

Kind regards,
SinDoc

-- 
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: : Google Chrome extension for TryClojure (try-clojure.org)

2010-05-31 Thread Sean Corfield
try-clojure.org seems to redirect to http://blog.licenser.net/ ??

On Mon, May 31, 2010 at 11:22 AM, sergey-miryanov
sergey.mirya...@gmail.com wrote:
 Missing link 
 https://chrome.google.com/extensions/detail/lhmgejcdhmollecbianopflcfdaennle
 ;)

 On 31 май, 16:04, sergey-miryanov sergey.mirya...@gmail.com wrote:
 Hi all,

  I made a little extension for google chrome. It allows to start try-
 clojure REPL via clicking on toolbar button. Also it grabs selected
 text and evaluates it in REPL.

 Feel free to comment, report bugs and suggestions.

 /Sergey

-- 
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: : Google Chrome extension for TryClojure (try-clojure.org)

2010-05-31 Thread Sean Corfield
Also the extension did not seem to work reliably on Chrome 5.0.375.55
beta on Mac OS X. Sometimes clicking the button did not open the
popup, sometimes it opened it blank. In most cases it spun up CPU to
near 100%. Only once did it open with the REPL on www.try-clojure.org
- but it is a cool idea!

On Mon, May 31, 2010 at 4:28 PM, Sean Corfield seancorfi...@gmail.com wrote:
 try-clojure.org seems to redirect to http://blog.licenser.net/ ??

 On Mon, May 31, 2010 at 11:22 AM, sergey-miryanov
 sergey.mirya...@gmail.com wrote:
 Missing link 
 https://chrome.google.com/extensions/detail/lhmgejcdhmollecbianopflcfdaennle
 ;)

 On 31 май, 16:04, sergey-miryanov sergey.mirya...@gmail.com wrote:
 Hi all,

  I made a little extension for google chrome. It allows to start try-
 clojure REPL via clicking on toolbar button. Also it grabs selected
 text and evaluates it in REPL.

 Feel free to comment, report bugs and suggestions.

 /Sergey

-- 
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: : Google Chrome extension for TryClojure (try-clojure.org)

2010-05-31 Thread Heinz N. Gies
The problem is known and in work, the background is that not all of the DNS 
entries can be configured directly a request with the DNS provider (which also 
hosts my blog) is already filed so I can't say how long this takes :).

Best regards,
Heinz N. Gies aka Licenser
On Jun 1, 2010, at 1:28 , Sean Corfield wrote:

 try-clojure.org seems to redirect to http://blog.licenser.net/ ??
 
 On Mon, May 31, 2010 at 11:22 AM, sergey-miryanov
 sergey.mirya...@gmail.com wrote:
 Missing link 
 https://chrome.google.com/extensions/detail/lhmgejcdhmollecbianopflcfdaennle
 ;)
 
 On 31 май, 16:04, sergey-miryanov sergey.mirya...@gmail.com wrote:
 Hi all,
 
  I made a little extension for google chrome. It allows to start try-
 clojure REPL via clicking on toolbar button. Also it grabs selected
 text and evaluates it in REPL.
 
 Feel free to comment, report bugs and suggestions.
 
 /Sergey
 
 -- 
 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: : Google Chrome extension for TryClojure (try-clojure.org)

2010-05-31 Thread Sean Corfield
Good to know. I'll reinstall it and look forward to using it once DNS
has propagated (if that's what's causing the problems with the
extension)...

On Mon, May 31, 2010 at 4:41 PM, Heinz N. Gies he...@licenser.net wrote:
 The problem is known and in work, the background is that not all of the DNS 
 entries can be configured directly a request with the DNS provider (which 
 also hosts my blog) is already filed so I can't say how long this takes :).

-- 
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: confused about getting started with compojure on google app engine

2010-05-31 Thread Frank Siebenlist
Now that would be a fantastic topic for one of Sean Devlin's Full Disclojure 
videocasts!!!

(just a subtle hint from a Full Disclojure fan...;-) )

-Frank.


On May 31, 2010, at 12:33 PM, Zitterbewegung wrote:

 I was wondering which tutorial I should use to get started with
 compojure on google app engine. There seem to be a bunch of them but
 they target old versions or slightly old versions. Which one should I
 use?
 
 -- 
 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


Reductions bug

2010-05-31 Thread Michael Jaaka
Hi!

Here it is:

(reduce + '())  gives 0

(reductions + '()) gives java.lang.IllegalArgumentException: Don't
know how to create ISeq from: java.lang.Integer

So reductions not always returns a sequence of intermediate values of
the reduction.

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


clojure.contrib.repl-utils show

2010-05-31 Thread looselytyped
Hi!

I created a new project using 'lein new project_name and then
modified the project.clj file to look like this -


(defproject datastructures 1.0.0-SNAPSHOT
:dependencies [[org.clojure/clojure 1.2.0-master-SNAPSHOT]
 [org.clojure/clojure-contrib 1.2.0-SNAPSHOT]
 [ant/ant 1.6.5]
 [jline 0.9.94]
 [org.apache.maven/maven-ant-tasks 2.0.10]]
  :dev-dependencies [[swank-clojure 1.2.1]
 [autodoc 0.7.0]])


I did a 'lein deps' and then a 'lein swank' - I switched over the
emacs and did a slime-connect [I am using the emacs-starter-kit with
clojure-mode, and swank-clojure installed via ELPA).

For some reason, the 'show' function from clojure.contrib.repl-utils
does not work. In fact the only completions I get when trying to get
to repl-* are

clojure.contrib.repl-ln
clojure.contrib.repl_ln

I noticed that there is now a clojure.repl namespace with a few
methods like apropos but no 'show'.

Furthermore, when using labrepl (from relevance) and doing a script/
swank 'show' works just fine.

Both lib directories contain the same jars

labrepl/lib = clojure-1.2.0-master-20100528.120302-79.jar
clojure-contrib-1.2.0-20100528.120551-119.jar
new_project/lib = clojure-1.2.0-master-20100528.120302-79.jar
clojure-contrib-1.2.0-20100528.120551-119.jar

Is there something I am missing?

Thank you!

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


Re: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-31 Thread Joonas Pulakka
I've been using Swing. But, one thing to consider is that many (most?)
big applications use extension libraries such as JIDE (https://jide-
oss.dev.java.net/), SwingX (https://swingx.dev.java.net/) or Flamingo
(https://flamingo.dev.java.net/). They contain extra widgets that have
their own extra APIs of course. So while abstracting the JDK
Swing (or any other toolkit) away would be a huge thing, it would be
somewhat lacking regardless.

Do you think the DSL you described would be easily extensible to work
with that kind of extension libraries? If not, maybe that could be one
reason to use a some other toolkit (more complete than basic Swing) as
a base for the DSL.

Best Regards,
Joonas

On May 27, 6:18 pm, Luke VanderHart luke.vanderh...@gmail.com wrote:
 My side project is a fairly complex GUI application written in
 Clojure. Recently, I've become irritated with using Java interop for
 everything. It's not that Clojure doesn't have nice java interop - it
 does. It's just that when interacting with a GUI framework, which is a
 large part of my app, I have to be back in mutable object-oriented
 land, worrying about class hierarchies, mutable state, locks, etc.
 Yucky.

 So, with a perhaps dangerous lack of sanity and without any guarantee
 of success, I've decided to try my hand at writing an idiomatic
 Clojure GUI library. If I have success (which I doubt) I will of
 course make it available as open source.

 I intend for it to be mostly declarative, with a nice DSL for defining
 GUI elements. Each component will also implement map, and use one of
 Clojure's reference types as an interface for inspecting / updating
 its state. I may also implement some aspects of Functional Reactive
 Programming wherever it's convenient to do so.

 What you all must help me decide is what GUI framework to use as the
 underpinnings of it. It's genuinely hard to decide. I have at least
 some experience with all of them, so I have no strong preference, but
 I'd like to get your input. I did consider trying to make it abstract
 enough that you could plug in *any* of them under the hood, but
 there's enough differences between the frameworks that that would get
 very ugly very fast.

 Possibilities are:

 AWT
 Pros: native widgets, bundled with Java, low-level
 Cons: few widgets, considered somewhat obselete

 Swing
 Pros: bundled with Java, good widget selection
 Cons: non-native widgets

 SWT
 Pros: native widgets, widely used
 Cons: requires platform-specific libs

 QT Jambi
 Pros: native widgets, huge widget selection, highly-regarded framework
 Cons: requires platform-specific libs, writing custom widgets is
 hairy, momentum and support seem to be lagging since Nokia dropped
 official support.

 Remember, the actual API won't matter - that will be completely
 abstracted away. So try to focus on the framework's look and feel.
 Also let me know if I've missed any of the framework's key
 characteristics.

 Thanks!

 -Luke

-- 
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: Reductions bug

2010-05-31 Thread Meikel Brandmeyer
Hi,

this is already filed:
http://www.assembla.com/spaces/clojure/tickets/362-incorrect-result-of-reductions-for-empty-input-sequences

Sincerely
Meikel

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


Re: clojure.contrib.repl-utils show

2010-05-31 Thread Meikel Brandmeyer
Hi,

On Jun 1, 4:16 am, looselytyped raju.gan...@gmail.com wrote:

 For some reason, the 'show' function from clojure.contrib.repl-utils
 does not work. In fact the only completions I get when trying to get
 to repl-* are

 clojure.contrib.repl-ln
 clojure.contrib.repl_ln

Did you (require 'clojure.contrib.repl-ln)? Maybe
labrepl does that for you.

Sincerely
Meikel

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