Re: see if any branch of a cond succeeded

2011-11-05 Thread Alan Malloy
On Nov 4, 11:49 pm, Baishampayan Ghose  wrote:
> On Sat, Nov 5, 2011 at 11:55 AM, Martin DeMello  
> wrote:
> > What's the cleanest way to run a piece of code if any branch of a cond
> > statement succeeded, without relying on the return value of the
> > individual clauses not to be nil?
>
> > For example, if I have the following piece of code that says I can
> > only move left or up
>
> > (cond
> >  (= dir :left) (move-left)
> >  (= dir :up)  (move-up))
>
> > but (move-left) or (move-up) could themselves return nil, is there any
> > nice way to check if one of them was called?
>
> What about something like this -
>
> (cond
>  (= dir :left) (move-left)
>  (= dir :up)  (move-up)
>  :else :nok)
>
> Or
>
> (cond
>  (= dir :left) [(move-left)]
>  (= dir :up)  [(move-up)])

Seconded. Though if you can't easily predict what move-left/move-up
might return (ie they might even return :nok) you might need to be
more careful. Use a namespaced keyword like :my-current-ns/didnt-do-
anything, or a gensym (or a fresh Object) for guaranteed uniqueness:

(let [nothing (Object.)
  cond-result (case dir :left (move-left) :up (move-up) nothing)]
  (if (identical? nothing cond-result)
...))

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that 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: see if any branch of a cond succeeded

2011-11-05 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

what about

>> (cond (= dir :left) ((move-left)(:ok)) (= dir :up)
>> ((move-up)(:ok)) :else :nok)

or whatever the exact syntax is


Am 05.11.2011 08:22, schrieb Alan Malloy:
> On Nov 4, 11:49 pm, Baishampayan Ghose  wrote:
>> On Sat, Nov 5, 2011 at 11:55 AM, Martin DeMello
>>  wrote:
>>> What's the cleanest way to run a piece of code if any branch of
>>> a cond statement succeeded, without relying on the return value
>>> of the individual clauses not to be nil?
>> 
>>> For example, if I have the following piece of code that says I
>>> can only move left or up
>> 
>>> (cond (= dir :left) (move-left) (= dir :up)  (move-up))
>> 
>>> but (move-left) or (move-up) could themselves return nil, is
>>> there any nice way to check if one of them was called?
>> 
>> What about something like this -
>> 
>> (cond (= dir :left) (move-left) (= dir :up)  (move-up) :else
>> :nok)
>> 
>> Or
>> 
>> (cond (= dir :left) [(move-left)] (= dir :up)  [(move-up)])
> 
> Seconded. Though if you can't easily predict what
> move-left/move-up might return (ie they might even return :nok) you
> might need to be more careful. Use a namespaced keyword like
> :my-current-ns/didnt-do- anything, or a gensym (or a fresh Object)
> for guaranteed uniqueness:
> 
> (let [nothing (Object.) cond-result (case dir :left (move-left) :up
> (move-up) nothing)] (if (identical? nothing cond-result) ...))
> 


- -- 

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

iQIcBAEBAgAGBQJOtP9TAAoJENRtux+h35aGZ6cQALNrIXvCpEUfrLFAYgauJVWP
8cvu+gXUgCDxxcJR41MOBfDvnVOJmeiCJp0LWH3HpYGD0M+7BfJxMoyg/tdrZggn
L5CSq+oXbeOUDe/7LV7E97u8/gZhHrRNELZGyWbgHX/d0VZpezH2QwMMQKTiwwAh
zxkyUHyahJ1+Li6hrFL/1CI8XwH7JEnjgyd4Zfj2BNkkAmgS2E+iBrGYb8vMQtLo
7Pm6WBrTRjNNyrIKi6axHij2SvKdPKSzbAR3oJPjhL+5yDhrvCdHk0AvzJjiTHsK
RMxaGYjR1/hRDt97+69iJu9hxjAOZSZeCYBid4vAPsdHu+qF/K5Ngr49rnWGFp9Y
g8GkznO7q4L2Lde5WW0GRtNAGTgElEp+9cS1PSxDgyzxEw9+SaJUNLxr5cCsCp8I
dI4Gu88gNgxT6AqomMcrIFd4LyHZ3HEW+rTuFcz4oCcmFQGXHqQVJQV6wbF1NpSf
8BuEskip4mTOdVvSfciC5jLjCO3q8xT/46TAYwhyrjUecEBR9FGy/e6ImN4DILiU
nd8RvvTMKayAo3OudBcM/dN1YRzc0UijAqhFzV6/thvPNARGobGqzqwE3zKAseLY
sPW1hKbJteDHHLBbG5Ia0/QyqdpXmSkyXjS8dahiuOefjuzWxeerGDaOl3wTiw/S
o3J73WASesJ1RulPjqeW
=M8Zh
-END PGP SIGNATURE-

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


Re: see if any branch of a cond succeeded

2011-11-05 Thread Alan Malloy
Assuming that you meant (do (move-left) (:ok)), this is insufficient
except in the rare case where he doesn't care about the return value
of move-left.

On Nov 5, 2:18 am, Dennis Haupt  wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> what about
>
> >> (cond (= dir :left) ((move-left)(:ok)) (= dir :up)
> >> ((move-up)(:ok)) :else :nok)
>
> or whatever the exact syntax is
>
> Am 05.11.2011 08:22, schrieb Alan Malloy:
>
>
>
>
>
>
>
>
>
> > On Nov 4, 11:49 pm, Baishampayan Ghose  wrote:
> >> On Sat, Nov 5, 2011 at 11:55 AM, Martin DeMello
> >>  wrote:
> >>> What's the cleanest way to run a piece of code if any branch of
> >>> a cond statement succeeded, without relying on the return value
> >>> of the individual clauses not to be nil?
>
> >>> For example, if I have the following piece of code that says I
> >>> can only move left or up
>
> >>> (cond (= dir :left) (move-left) (= dir :up)  (move-up))
>
> >>> but (move-left) or (move-up) could themselves return nil, is
> >>> there any nice way to check if one of them was called?
>
> >> What about something like this -
>
> >> (cond (= dir :left) (move-left) (= dir :up)  (move-up) :else
> >> :nok)
>
> >> Or
>
> >> (cond (= dir :left) [(move-left)] (= dir :up)  [(move-up)])
>
> > Seconded. Though if you can't easily predict what
> > move-left/move-up might return (ie they might even return :nok) you
> > might need to be more careful. Use a namespaced keyword like
> > :my-current-ns/didnt-do- anything, or a gensym (or a fresh Object)
> > for guaranteed uniqueness:
>
> > (let [nothing (Object.) cond-result (case dir :left (move-left) :up
> > (move-up) nothing)] (if (identical? nothing cond-result) ...))
>
> - --
>
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v2.0.14 (MingW32)
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org/
>
> iQIcBAEBAgAGBQJOtP9TAAoJENRtux+h35aGZ6cQALNrIXvCpEUfrLFAYgauJVWP
> 8cvu+gXUgCDxxcJR41MOBfDvnVOJmeiCJp0LWH3HpYGD0M+7BfJxMoyg/tdrZggn
> L5CSq+oXbeOUDe/7LV7E97u8/gZhHrRNELZGyWbgHX/d0VZpezH2QwMMQKTiwwAh
> zxkyUHyahJ1+Li6hrFL/1CI8XwH7JEnjgyd4Zfj2BNkkAmgS2E+iBrGYb8vMQtLo
> 7Pm6WBrTRjNNyrIKi6axHij2SvKdPKSzbAR3oJPjhL+5yDhrvCdHk0AvzJjiTHsK
> RMxaGYjR1/hRDt97+69iJu9hxjAOZSZeCYBid4vAPsdHu+qF/K5Ngr49rnWGFp9Y
> g8GkznO7q4L2Lde5WW0GRtNAGTgElEp+9cS1PSxDgyzxEw9+SaJUNLxr5cCsCp8I
> dI4Gu88gNgxT6AqomMcrIFd4LyHZ3HEW+rTuFcz4oCcmFQGXHqQVJQV6wbF1NpSf
> 8BuEskip4mTOdVvSfciC5jLjCO3q8xT/46TAYwhyrjUecEBR9FGy/e6ImN4DILiU
> nd8RvvTMKayAo3OudBcM/dN1YRzc0UijAqhFzV6/thvPNARGobGqzqwE3zKAseLY
> sPW1hKbJteDHHLBbG5Ia0/QyqdpXmSkyXjS8dahiuOefjuzWxeerGDaOl3wTiw/S
> o3J73WASesJ1RulPjqeW
> =M8Zh
> -END PGP SIGNATURE-

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


get all record instances

2011-11-05 Thread Colin Taylor
Hi,

given a namespace sources

with [simplified definitions]

(defrecord Source [name url])

(def google (source "Google" "google.com"))
(def bbc (source "BBC" "bbc.co.uk"))
(def nbc ...
etc.

what would be the idiomatic way to implement

(defn get-all-sources)

cheers
Colin

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


Re: get all record instances

2011-11-05 Thread Mark Derricutt
Would something like:

(def ^:dynamic *SOURCES* (ref []))
(defrecord Source [name url])
(defmacro defsource [name url]
  `(dosync (alter *SOURCES* conj (Source. ~name ~url
(defn get-all-sources [] @*SOURCES*)

(defsource "Google" "google.com")

do ok?

Man - it's been too long since I've done clojure - so rusty :)



-- 
"Great artists are extremely selfish and arrogant things" — Steven Wilson,
Porcupine Tree


On Sat, Nov 5, 2011 at 11:03 PM, Colin Taylor wrote:

> Hi,
>
> given a namespace sources
>
> with [simplified definitions]
>
> (defrecord Source [name url])
>
> (def google (source "Google" "google.com"))
> (def bbc (source "BBC" "bbc.co.uk"))
> (def nbc ...
> etc.
>
> what would be the idiomatic way to implement
>
> (defn get-all-sources)
>
> cheers
> Colin
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that 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

problems of a newbie

2011-11-05 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

hi,

i'm half done with my asteroids clone. i stumbled over a few problems
and wanted to know how others already solved them :)

i am used to "less concrete programming". i ask my tools to do the
actual analysis and coding for me:
* where is that used?
* rename that
* show me all errors
* add a parameter here
* autocomplete this for me, i am too lazy to even remember the exact
method name
* show me a list of all methods and fields starting with an "e" that
fit in here. i know the one i want is in that list.

as elegant as clojure may be as a language, it's dragging me down to
almost native text editing which i did more than 10 years ago when i
wrote a game in turbo pascal.

how did you solve these problem and get some tool-support? or don't
you miss it because of something i am not aware of?



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

iQIcBAEBAgAGBQJOtSkdAAoJENRtux+h35aGeeQP+gJbQdNSZEdEIgjVFC/VZvRe
z1Rh9Z8xVwxbuyl/kx1GMLU3jZxJKkhp0OIp7RLbDgjwFFzwBnQ0CZSeuHd9bFD/
S5Vmf6tXB4AdC3u3a7wZilEQuSuq+ARtJhMKdGIQfoXgqDYA7JwOvV8ZkpiR2T2d
pKqswheRVstBqo9/xyinfuLsJMujDlF9NshoIC0n1b/L4tzddq/kgzIATcg/NJ4N
I0Qd1lqGC1THU2nHtiaSR66KQE5Ciq22FN0nVoT3jW9EU/kJ9tao7L6SUTY3tcaA
th8mxKLYId/NrbRmsYUTyWe6O30HAUTLLFEnImYTW2fUMdwRYeAoZGc7t5V3yJ/p
dU4JN0dGA/ADbdTItykaao1DtGI2/kGe6p9VaKk3IPCVAOio9UwgOCUQylTKqy7M
CWbrDcSFCQs5pTY1Sw5We9LV2VOBoTsai6vH/qE7t98mJLVf0wHvLLIBOkf/QO5a
HuSyCJRpOrWQF2jbooDqAbaJAa6huxLQjMeO9Ri4sDx2gDRYsf9Fmdjp4TFWWjdZ
O5HEzhUR165peQHo4RQLLf8dnlkibsdbx60n+VJ0E4iE7ID+hBOFC76bAllnAS1K
Q8HqXUogMi/ZLXIAB4BA83q71IEDVcytuYAn9Ku2FQLrmWCiOD57uMhSLjtzK/8J
TIuaLwipARdzsqi/piwl
=MnRq
-END PGP SIGNATURE-

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


Access to unzipped assets within jars

2011-11-05 Thread Sam Aaron
Hi there,

consider there exists foo.jar on Clojars which contains a bunch of asset files 
i.e. png images. If I were to declare foo as one of my project's dependencies, 
is it possible to get access to those asset files? I essentially want a path to 
a non-zipped version of each asset.

Sam

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

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that 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: Access to unzipped assets within jars

2011-11-05 Thread Ben Smith-Mannschott
On Sat, Nov 5, 2011 at 14:42, Sam Aaron  wrote:
> Hi there,
>
> consider there exists foo.jar on Clojars which contains a bunch of asset 
> files i.e. png images. If I were to declare foo as one of my project's 
> dependencies, is it possible to get access to those asset files? I 
> essentially want a path to a non-zipped version of each asset.

These kinds of assets are known as "resources" in java parlance. A
resource is named by a path relative to an entry in the classpath.
Declaring foo as a dependency will place it in the classpath. The name
of the resource will therefore be the path of the asset within
foo.jar.

Give clojure.java.io/resource [1] that name, and it will return a URL.

Pass that URL to clojure.java.io/input-stream [2] to open the resource
for reading.

[1] 
http://clojure.github.com/clojure/clojure.java.io-api.html#clojure.java.io/resource

[2] 
http://clojure.github.com/clojure/clojure.java.io-api.html#clojure.java.io/input-stream

hth,
Ben

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


Re: Access to unzipped assets within jars

2011-11-05 Thread Baishampayan Ghose
Sam,

> consider there exists foo.jar on Clojars which contains a bunch of asset 
> files i.e. png images. If I were to declare foo as one of my
> project's dependencies, is it possible to get access to those asset files? I 
> essentially want a path to a non-zipped version of each
> asset.

I think `clojure.java.io/resource` will do the trick for you. You just
need to know the path to the png file inside the JAR and as long as
the JAR is in your classpath, you should be able to read it.

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.com

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


ClojureScript: Mini Model View Presenter library announcement

2011-11-05 Thread Dima Belikov
Hi,

https://github.com/dbelikov/Mini-MVP

Introduction

The main goal for Mini-MVP (Model View Presenter) library is to
clearly separate your models from business logic and UI representation
while maintaining their relationships in a concise and well-defined
manner.

Let's say you have some data model that you'd like to use.
(def my-model (mvp/create { :type Text :hint "Enter your age" :value
"1234" :error "Value too big to be true" }))

You define a control that will render the text from the model. I'm
using jQuery here, the sample also demonstrates Closure.

;; Defines a subscriber that will update control's value if the model
changes.
(mvp/add-reader text-model [:text] #(.val (jq "#text2") (:new-value
%)))

;; In a similar way, we also render the error message
(mvp/add-reader my-model [:error] #(.html (jq "#error-message") (:new-
value %)))

;; let's update the error message if the age exceeds 120
(mvp/add-writer my-model [:value]
  #(if (> (:new-value %) 120)
 (mvp/assoc-value my-model [:error] "Value too big
to be true")
 (mvp/assoc-value my-model [:error] "")))

;; finally, update the model when the age is changed
(.change (jq "#input-control") #(mvp/assoc-value my-model [:value] (.
(jq "#input-control") (val

Now, if you enter any age less than 120, the error message is cleared.
Enter more than 120 and it'll show up again.




API

create   
   Creates a new MVP model

create-ref  
   Creates a model that references a subpath in the parent model

get-version 
   Answers the current version of the model. Each change causes
version change.
   Assigning equal values is a no-op that doesn't cause version
change.

get-value  [path] 
   Similar to clojure.core/get-in, gets the value in the model
under the specified path.
   Empty path fetches the root of the model.

update-value  [path]  
   Similar to clojure.core/update-in, updates the model's value
under the specified path. The specified function is invoked to get the
new value.
   Producing equal value will be considered a no-op.

assoc-value  [path] 
   Similar to clojure.core/assoc-in, associates a new value with
the sub-model at the specified path.
   Producing equal value will be considered a no-op.

add-writer  [path] 
   Adds a 1st phase function that will be invoked if the value
under the specified path changes.
   The function is not invoked if the change(s) didn't cause value
change.
   I.e. given a model { :first "CA" :second "NY" } which is being
updated to { :first "WA" :second "NY" },
   the subscriber for :second isn't invoked. The subscribers for
[] and [:first] are to be called.

add-reader  [path] 
   Exactly the same as add-writer, but these folks are invoked
after all writers.
   The idea is to avoid unnecessary UI rendering/flickering while
validators/statistics get updated.

clear  [path]
   Eliminates all subscribers under the specified path.

delay-events  
   All subscriber calls are delayed until after the function
completes.
   Only subscribers which guarded value has changed will be
called.
   I.e. given a subscriber for path=[1] in a model ["a" "b" "c"],
three subsequent changes within (delay-events ...)
   ["a" "b" "c"] -> ["b" "c" "d"] -> ["e" "f" "g"] -> ["h" "b"
"e"] won't trigger the subscriber.

version 
   Returns the current version of the model. By default, a new
unique identifier is generated after each actual change.
   You can define the initial version and a function to generate
new versions:
   (mvp/create {...my data...} 12 inc)  ;; will start with
version=12, which is incremented upon each change




License

Same as Clojure/ClojureScript.


Cheers,
Dima

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that 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


A question on deftest- macro.

2011-11-05 Thread Young Kim
My development environment on Windows 7 is as follows.

--
C:\work> lein version
Leiningen 1.6.2-SNAPSHOT on Java 1.7.0 Java HotSpot(TM) Client VM
--

I created a new project with leiningen like this.

--
C:\work> lein new myproject
Created new project in: C:\work\myproject
Look over project.clj and start coding in myproject/core.clj
--

And then, I edited  C:/work/myproject/test/myproject/test/core.clj
like this.

--
;; file: C:/work/myproject/test/myproject/test/core.clj
(ns myproject.test.core
  (:use [clojure.test]) )

(deftest- add
  (is (= 3 (+ 1 2)))
  (is (= 8 (+ 3 5))) )

(deftest- subtract
  (is (= 5 (- 10 5)))
  (is (= 2 (- 7 5))) )

(deftest arithmetic
  (add)
  (subtract) )


And I tested the above code like this.

-
c:\work\myproject> lein test
Testing myproject.test.core
Ran 5 tests containing 8 assertions.
0 failures, 0 errors.
--

The unexpected result was that the message "Ran 5 tests containing 8
assertions".

The expected message was that "Ran 3 tests containing 4 assertions",
because of two dertest- macros in my test code.

How can I block the execution of the two private deftest- macros in my
test code?

Thanks a lot in advance for anyone who replys my question..

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that 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 Conj extracurricular activities spreadsheet

2011-11-05 Thread Doug South
On 04/11/2011, at 9:16 PM, Michael Fogus  wrote:

>> Any thoughts about when / where these events can take place?
> 
> At this point it would be great if a Conj-planning heavyweight could
> step in and provide some additional ideas... although solutions would
> be great too.  :-)

According to the conference schedule the conference room is available until 
11pm on Thursday. I don't know how big the room is, but as long as the Overtone 
folks don't get too loud ;), that might be a good place and time to have a mini 
open conference. As long as all the people involved take responsibility for 
returning the room to it's "conference state" at the end of the night, that 
might work well?

Regards,
Doug

Sent from my iPhone

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that 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: Access to unzipped assets within jars

2011-11-05 Thread Sam Aaron
Interesting - thanks for this. So is it fair to assume that the JVM is ok with 
reading URL resources that are zipped in a jar. I also assume to have an actual 
non-zipped version of the resource I need to copy the file from inside the 
zipped jar to an external path in my file system?

Sam

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

On 5 Nov 2011, at 14:03, Ben Smith-Mannschott wrote:

> On Sat, Nov 5, 2011 at 14:42, Sam Aaron  wrote:
>> Hi there,
>> 
>> consider there exists foo.jar on Clojars which contains a bunch of asset 
>> files i.e. png images. If I were to declare foo as one of my project's 
>> dependencies, is it possible to get access to those asset files? I 
>> essentially want a path to a non-zipped version of each asset.
> 
> These kinds of assets are known as "resources" in java parlance. A
> resource is named by a path relative to an entry in the classpath.
> Declaring foo as a dependency will place it in the classpath. The name
> of the resource will therefore be the path of the asset within
> foo.jar.
> 
> Give clojure.java.io/resource [1] that name, and it will return a URL.
> 
> Pass that URL to clojure.java.io/input-stream [2] to open the resource
> for reading.
> 
> [1] 
> http://clojure.github.com/clojure/clojure.java.io-api.html#clojure.java.io/resource
> 
> [2] 
> http://clojure.github.com/clojure/clojure.java.io-api.html#clojure.java.io/input-stream
> 
> hth,
> Ben
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that 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


Solving this with logic programing

2011-11-05 Thread Michael Jaaka
Hi,

I would like to use logic programing to describe permissions. The
definition is

We have set of triples which looks like:
Set of roles; set of operations; set of states

Triples are defined in scope of some entity with states, wildcard is
defined with _

All I need is to answer on some operation invocation if given user
with his role is able to execute that operation for particular entity
which is in one of its states

Example:
Roles: admin, operator, auditor
Entity: data form with states dirty, applied, rejected, executed
Operations on data form: reject, acept, list, enter
Triples of permissions:
admin, operator; reject, accept; applied
auditor, operator; list; _
operator; enter; dirty

The additional question beside checking permission is:
What are operations avaiable for given role and given state of entity


Any thoughts? Maybe core.logic? It seems that I know its purpose but
don't know how to use it.
Thanks in advance.

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


Re: get all record instances

2011-11-05 Thread gaz jones
could you not just use a map?

(def sources {:bbc "bbc.co.uk" :google "google.com" ...})


On Sat, Nov 5, 2011 at 6:14 AM, Mark Derricutt  wrote:
> Would something like:
> (def ^:dynamic *SOURCES* (ref []))
> (defrecord Source [name url])
> (defmacro defsource [name url]
>   `(dosync (alter *SOURCES* conj (Source. ~name ~url
> (defn get-all-sources [] @*SOURCES*)
> (defsource "Google" "google.com")
> do ok?
> Man - it's been too long since I've done clojure - so rusty :)
>
>
> --
> "Great artists are extremely selfish and arrogant things" — Steven Wilson,
> Porcupine Tree
>
>
> On Sat, Nov 5, 2011 at 11:03 PM, Colin Taylor 
> wrote:
>>
>> Hi,
>>
>> given a namespace sources
>>
>> with [simplified definitions]
>>
>> (defrecord Source [name url])
>>
>> (def google (source "Google" "google.com"))
>> (def bbc (source "BBC" "bbc.co.uk"))
>> (def nbc ...
>> etc.
>>
>> what would be the idiomatic way to implement
>>
>> (defn get-all-sources)
>>
>> cheers
>> Colin
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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


Re: Solving this with logic programing

2011-11-05 Thread Ambrose Bonnaire-Sergeant
Hey Michael,

Here's a solution using core.logic.

;; We can define a "permission" relation with "defrel".

(defrel permission roles ops state)

;; and a helper function to add each combination of permissions

(defn add-permision [roles ops states]
  (for [r roles
o ops
s states]
(fact permission r o s)))

;; Here is your first example

(add-permision #{:admin :operator} #{:reject :accept} #{:applied})

;; Now lets ask what are the permissions for the :admin role

logic-introduction.perm=> (run* [q]
(fresh [ops states]
   (permission :admin ops states)
   (== q [ops states])))
([:reject :applied] [:accept :applied])

;; Ask what permissions either a :admin or :operator role has

logic-introduction.perm=> (run* [q]
(fresh [role ops states]
   (conde
 ((== role :admin))
 ((== role :operator)))
   (== q [ops states])
   (permission role ops states)))
([:reject :applied] [:accept :applied] [:reject :applied] [:accept
:applied])


Thanks,
Ambrose

On Sun, Nov 6, 2011 at 12:51 AM, Michael Jaaka  wrote:

> Hi,
>
> I would like to use logic programing to describe permissions. The
> definition is
>
> We have set of triples which looks like:
> Set of roles; set of operations; set of states
>
> Triples are defined in scope of some entity with states, wildcard is
> defined with _
>
> All I need is to answer on some operation invocation if given user
> with his role is able to execute that operation for particular entity
> which is in one of its states
>
> Example:
> Roles: admin, operator, auditor
> Entity: data form with states dirty, applied, rejected, executed
> Operations on data form: reject, acept, list, enter
> Triples of permissions:
> admin, operator; reject, accept; applied
> auditor, operator; list; _
> operator; enter; dirty
>
> The additional question beside checking permission is:
> What are operations avaiable for given role and given state of entity
>
>
> Any thoughts? Maybe core.logic? It seems that I know its purpose but
> don't know how to use it.
> Thanks in advance.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that 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: Solving this with logic programing

2011-11-05 Thread Ambrose Bonnaire-Sergeant
I gave the wildcard requirement a bit of thought, no inspiration at the
moment.

Maybe someone else can suggest a strategy.

Ambrose

On Sun, Nov 6, 2011 at 1:14 AM, Ambrose Bonnaire-Sergeant <
abonnaireserge...@gmail.com> wrote:

> Hey Michael,
>
> Here's a solution using core.logic.
>
> ;; We can define a "permission" relation with "defrel".
>
> (defrel permission roles ops state)
>
> ;; and a helper function to add each combination of permissions
>
> (defn add-permision [roles ops states]
>   (for [r roles
> o ops
> s states]
> (fact permission r o s)))
>
> ;; Here is your first example
>
> (add-permision #{:admin :operator} #{:reject :accept} #{:applied})
>
> ;; Now lets ask what are the permissions for the :admin role
>
> logic-introduction.perm=> (run* [q]
> (fresh [ops states]
>(permission :admin ops states)
>(== q [ops states])))
> ([:reject :applied] [:accept :applied])
>
> ;; Ask what permissions either a :admin or :operator role has
>
> logic-introduction.perm=> (run* [q]
> (fresh [role ops states]
>(conde
>  ((== role :admin))
>  ((== role :operator)))
>(== q [ops states])
>(permission role ops states)))
> ([:reject :applied] [:accept :applied] [:reject :applied] [:accept
> :applied])
>
>
> Thanks,
> Ambrose
>
> On Sun, Nov 6, 2011 at 12:51 AM, Michael Jaaka <
> michael.ja...@googlemail.com> wrote:
>
>> Hi,
>>
>> I would like to use logic programing to describe permissions. The
>> definition is
>>
>> We have set of triples which looks like:
>> Set of roles; set of operations; set of states
>>
>> Triples are defined in scope of some entity with states, wildcard is
>> defined with _
>>
>> All I need is to answer on some operation invocation if given user
>> with his role is able to execute that operation for particular entity
>> which is in one of its states
>>
>> Example:
>> Roles: admin, operator, auditor
>> Entity: data form with states dirty, applied, rejected, executed
>> Operations on data form: reject, acept, list, enter
>> Triples of permissions:
>> admin, operator; reject, accept; applied
>> auditor, operator; list; _
>> operator; enter; dirty
>>
>> The additional question beside checking permission is:
>> What are operations avaiable for given role and given state of entity
>>
>>
>> Any thoughts? Maybe core.logic? It seems that I know its purpose but
>> don't know how to use it.
>> Thanks in advance.
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that 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: Solving this with logic programing

2011-11-05 Thread David Nolen
For wildcards you can use symbol-macrolet from tools.macro

(macro/symbol-macrolet [_ (lvar)]
   (all
(== [_ _ [_ _ 'milk _ _] _ _] hs)
))


On Sat, Nov 5, 2011 at 1:24 PM, Ambrose Bonnaire-Sergeant <
abonnaireserge...@gmail.com> wrote:

> I gave the wildcard requirement a bit of thought, no inspiration at the
> moment.
>
> Maybe someone else can suggest a strategy.
>
> Ambrose
>
>
> On Sun, Nov 6, 2011 at 1:14 AM, Ambrose Bonnaire-Sergeant <
> abonnaireserge...@gmail.com> wrote:
>
>> Hey Michael,
>>
>> Here's a solution using core.logic.
>>
>> ;; We can define a "permission" relation with "defrel".
>>
>> (defrel permission roles ops state)
>>
>> ;; and a helper function to add each combination of permissions
>>
>> (defn add-permision [roles ops states]
>>   (for [r roles
>> o ops
>> s states]
>> (fact permission r o s)))
>>
>> ;; Here is your first example
>>
>> (add-permision #{:admin :operator} #{:reject :accept} #{:applied})
>>
>> ;; Now lets ask what are the permissions for the :admin role
>>
>> logic-introduction.perm=> (run* [q]
>> (fresh [ops states]
>>(permission :admin ops states)
>>(== q [ops states])))
>> ([:reject :applied] [:accept :applied])
>>
>> ;; Ask what permissions either a :admin or :operator role has
>>
>> logic-introduction.perm=> (run* [q]
>> (fresh [role ops states]
>>(conde
>>  ((== role :admin))
>>  ((== role :operator)))
>>(== q [ops states])
>>(permission role ops states)))
>> ([:reject :applied] [:accept :applied] [:reject :applied] [:accept
>> :applied])
>>
>>
>> Thanks,
>> Ambrose
>>
>> On Sun, Nov 6, 2011 at 12:51 AM, Michael Jaaka <
>> michael.ja...@googlemail.com> wrote:
>>
>>> Hi,
>>>
>>> I would like to use logic programing to describe permissions. The
>>> definition is
>>>
>>> We have set of triples which looks like:
>>> Set of roles; set of operations; set of states
>>>
>>> Triples are defined in scope of some entity with states, wildcard is
>>> defined with _
>>>
>>> All I need is to answer on some operation invocation if given user
>>> with his role is able to execute that operation for particular entity
>>> which is in one of its states
>>>
>>> Example:
>>> Roles: admin, operator, auditor
>>> Entity: data form with states dirty, applied, rejected, executed
>>> Operations on data form: reject, acept, list, enter
>>> Triples of permissions:
>>> admin, operator; reject, accept; applied
>>> auditor, operator; list; _
>>> operator; enter; dirty
>>>
>>> The additional question beside checking permission is:
>>> What are operations avaiable for given role and given state of entity
>>>
>>>
>>> Any thoughts? Maybe core.logic? It seems that I know its purpose but
>>> don't know how to use it.
>>> Thanks in advance.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clojure@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+unsubscr...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>
>>
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

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

Re: Solving this with logic programing

2011-11-05 Thread Michael Jaaka

Thanks, it gave me insight into that framework.
Unfortunately it doesn't look friendly in usage.
Looks like there is a place for a clojure lib or wrapper around
core.logic.
It would be nice if it could answer to questions also in terms of
truth.

On 5 Lis, 18:24, Ambrose Bonnaire-Sergeant
 wrote:
> I gave the wildcard requirement a bit of thought, no inspiration at the
> moment.
>
> Maybe someone else can suggest a strategy.
>
> Ambrose
>
> On Sun, Nov 6, 2011 at 1:14 AM, Ambrose Bonnaire-Sergeant <
>
>
>
>
>
>
>
> abonnaireserge...@gmail.com> wrote:
> > Hey Michael,
>
> > Here's a solution using core.logic.
>
> > ;; We can define a "permission" relation with "defrel".
>
> > (defrel permission roles ops state)
>
> > ;; and a helper function to add each combination of permissions
>
> > (defn add-permision [roles ops states]
> >   (for [r roles
> >         o ops
> >         s states]
> >     (fact permission r o s)))
>
> > ;; Here is your first example
>
> > (add-permision #{:admin :operator} #{:reject :accept} #{:applied})
>
> > ;; Now lets ask what are the permissions for the :admin role
>
> > logic-introduction.perm=> (run* [q]
> >                                 (fresh [ops states]
> >                                        (permission :admin ops states)
> >                                        (== q [ops states])))
> > ([:reject :applied] [:accept :applied])
>
> > ;; Ask what permissions either a :admin or :operator role has
>
> > logic-introduction.perm=> (run* [q]
> >                                 (fresh [role ops states]
> >                                        (conde
> >                                          ((== role :admin))
> >                                          ((== role :operator)))
> >                                        (== q [ops states])
> >                                        (permission role ops states)))
> > ([:reject :applied] [:accept :applied] [:reject :applied] [:accept
> > :applied])
>
> > Thanks,
> > Ambrose
>
> > On Sun, Nov 6, 2011 at 12:51 AM, Michael Jaaka <
> > michael.ja...@googlemail.com> wrote:
>
> >> Hi,
>
> >> I would like to use logic programing to describe permissions. The
> >> definition is
>
> >> We have set of triples which looks like:
> >> Set of roles; set of operations; set of states
>
> >> Triples are defined in scope of some entity with states, wildcard is
> >> defined with _
>
> >> All I need is to answer on some operation invocation if given user
> >> with his role is able to execute that operation for particular entity
> >> which is in one of its states
>
> >> Example:
> >> Roles: admin, operator, auditor
> >> Entity: data form with states dirty, applied, rejected, executed
> >> Operations on data form: reject, acept, list, enter
> >> Triples of permissions:
> >> admin, operator; reject, accept; applied
> >> auditor, operator; list; _
> >> operator; enter; dirty
>
> >> The additional question beside checking permission is:
> >> What are operations avaiable for given role and given state of entity
>
> >> Any thoughts? Maybe core.logic? It seems that I know its purpose but
> >> don't know how to use it.
> >> Thanks in advance.
>
> >> --
> >> You received this message because you are subscribed to the Google
> >> Groups "Clojure" group.
> >> To post to this group, send email to clojure@googlegroups.com
> >> Note that 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: Solving this with logic programing

2011-11-05 Thread David Nolen
I would probably write the code like this:

(defrel permission role op state)

(defn add-permision [roles ops states]
  (doseq [r roles o ops s states]
(fact permission r o s)))

(add-permision #{:admin :operator} #{:reject :accept} #{:applied})

(defn permissiono [role op state]
(run* [q]
  (permission role op state)
  (== q {:role role :op op :state state})))

(permissiono :admin (lvar) (lvar))

;; ({:role :admin, :op :reject, :state :applied}
;;  {:role :admin, :op :accept, :state :applied})

We can use (lvar) for wildcards. If nothing can satisfy the query you'll
get back an empty sequences.

What in particular do you find unsatisfactory about this interface?

On Sat, Nov 5, 2011 at 2:46 PM, Michael Jaaka
wrote:

>
> Thanks, it gave me insight into that framework.
> Unfortunately it doesn't look friendly in usage.
> Looks like there is a place for a clojure lib or wrapper around
> core.logic.
> It would be nice if it could answer to questions also in terms of
> truth.
>
> On 5 Lis, 18:24, Ambrose Bonnaire-Sergeant
>  wrote:
> > I gave the wildcard requirement a bit of thought, no inspiration at the
> > moment.
> >
> > Maybe someone else can suggest a strategy.
> >
> > Ambrose
> >
> > On Sun, Nov 6, 2011 at 1:14 AM, Ambrose Bonnaire-Sergeant <
> >
> >
> >
> >
> >
> >
> >
> > abonnaireserge...@gmail.com> wrote:
> > > Hey Michael,
> >
> > > Here's a solution using core.logic.
> >
> > > ;; We can define a "permission" relation with "defrel".
> >
> > > (defrel permission roles ops state)
> >
> > > ;; and a helper function to add each combination of permissions
> >
> > > (defn add-permision [roles ops states]
> > >   (for [r roles
> > > o ops
> > > s states]
> > > (fact permission r o s)))
> >
> > > ;; Here is your first example
> >
> > > (add-permision #{:admin :operator} #{:reject :accept} #{:applied})
> >
> > > ;; Now lets ask what are the permissions for the :admin role
> >
> > > logic-introduction.perm=> (run* [q]
> > > (fresh [ops states]
> > >(permission :admin ops states)
> > >(== q [ops states])))
> > > ([:reject :applied] [:accept :applied])
> >
> > > ;; Ask what permissions either a :admin or :operator role has
> >
> > > logic-introduction.perm=> (run* [q]
> > > (fresh [role ops states]
> > >(conde
> > >  ((== role :admin))
> > >  ((== role :operator)))
> > >(== q [ops states])
> > >(permission role ops states)))
> > > ([:reject :applied] [:accept :applied] [:reject :applied] [:accept
> > > :applied])
> >
> > > Thanks,
> > > Ambrose
> >
> > > On Sun, Nov 6, 2011 at 12:51 AM, Michael Jaaka <
> > > michael.ja...@googlemail.com> wrote:
> >
> > >> Hi,
> >
> > >> I would like to use logic programing to describe permissions. The
> > >> definition is
> >
> > >> We have set of triples which looks like:
> > >> Set of roles; set of operations; set of states
> >
> > >> Triples are defined in scope of some entity with states, wildcard is
> > >> defined with _
> >
> > >> All I need is to answer on some operation invocation if given user
> > >> with his role is able to execute that operation for particular entity
> > >> which is in one of its states
> >
> > >> Example:
> > >> Roles: admin, operator, auditor
> > >> Entity: data form with states dirty, applied, rejected, executed
> > >> Operations on data form: reject, acept, list, enter
> > >> Triples of permissions:
> > >> admin, operator; reject, accept; applied
> > >> auditor, operator; list; _
> > >> operator; enter; dirty
> >
> > >> The additional question beside checking permission is:
> > >> What are operations avaiable for given role and given state of entity
> >
> > >> Any thoughts? Maybe core.logic? It seems that I know its purpose but
> > >> don't know how to use it.
> > >> Thanks in advance.
> >
> > >> --
> > >> You received this message because you are subscribed to the Google
> > >> Groups "Clojure" group.
> > >> To post to this group, send email to clojure@googlegroups.com
> > >> Note that 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/grou

Re: Solving this with logic programing

2011-11-05 Thread Michael Jaaka

Now is ok, easy to grasp. How the lein dep declaration and clj import
looks?
Thank you both.

On 5 Lis, 20:11, David Nolen  wrote:
> I would probably write the code like this:
>
> (defrel permission role op state)
>
> (defn add-permision [roles ops states]
>   (doseq [r roles o ops s states]
>     (fact permission r o s)))
>
> (add-permision #{:admin :operator} #{:reject :accept} #{:applied})
>
> (defn permissiono [role op state]
>     (run* [q]
>       (permission role op state)
>       (== q {:role role :op op :state state})))
>
> (permissiono :admin (lvar) (lvar))
>
> ;; ({:role :admin, :op :reject, :state :applied}
> ;;  {:role :admin, :op :accept, :state :applied})
>
> We can use (lvar) for wildcards. If nothing can satisfy the query you'll
> get back an empty sequences.
>
> What in particular do you find unsatisfactory about this interface?
>
> On Sat, Nov 5, 2011 at 2:46 PM, Michael Jaaka
> wrote:
>
>
>
>
>
>
>
>
>
> > Thanks, it gave me insight into that framework.
> > Unfortunately it doesn't look friendly in usage.
> > Looks like there is a place for a clojure lib or wrapper around
> > core.logic.
> > It would be nice if it could answer to questions also in terms of
> > truth.
>
> > On 5 Lis, 18:24, Ambrose Bonnaire-Sergeant
> >  wrote:
> > > I gave the wildcard requirement a bit of thought, no inspiration at the
> > > moment.
>
> > > Maybe someone else can suggest a strategy.
>
> > > Ambrose
>
> > > On Sun, Nov 6, 2011 at 1:14 AM, Ambrose Bonnaire-Sergeant <
>
> > > abonnaireserge...@gmail.com> wrote:
> > > > Hey Michael,
>
> > > > Here's a solution using core.logic.
>
> > > > ;; We can define a "permission" relation with "defrel".
>
> > > > (defrel permission roles ops state)
>
> > > > ;; and a helper function to add each combination of permissions
>
> > > > (defn add-permision [roles ops states]
> > > >   (for [r roles
> > > >         o ops
> > > >         s states]
> > > >     (fact permission r o s)))
>
> > > > ;; Here is your first example
>
> > > > (add-permision #{:admin :operator} #{:reject :accept} #{:applied})
>
> > > > ;; Now lets ask what are the permissions for the :admin role
>
> > > > logic-introduction.perm=> (run* [q]
> > > >                                 (fresh [ops states]
> > > >                                        (permission :admin ops states)
> > > >                                        (== q [ops states])))
> > > > ([:reject :applied] [:accept :applied])
>
> > > > ;; Ask what permissions either a :admin or :operator role has
>
> > > > logic-introduction.perm=> (run* [q]
> > > >                                 (fresh [role ops states]
> > > >                                        (conde
> > > >                                          ((== role :admin))
> > > >                                          ((== role :operator)))
> > > >                                        (== q [ops states])
> > > >                                        (permission role ops states)))
> > > > ([:reject :applied] [:accept :applied] [:reject :applied] [:accept
> > > > :applied])
>
> > > > Thanks,
> > > > Ambrose
>
> > > > On Sun, Nov 6, 2011 at 12:51 AM, Michael Jaaka <
> > > > michael.ja...@googlemail.com> wrote:
>
> > > >> Hi,
>
> > > >> I would like to use logic programing to describe permissions. The
> > > >> definition is
>
> > > >> We have set of triples which looks like:
> > > >> Set of roles; set of operations; set of states
>
> > > >> Triples are defined in scope of some entity with states, wildcard is
> > > >> defined with _
>
> > > >> All I need is to answer on some operation invocation if given user
> > > >> with his role is able to execute that operation for particular entity
> > > >> which is in one of its states
>
> > > >> Example:
> > > >> Roles: admin, operator, auditor
> > > >> Entity: data form with states dirty, applied, rejected, executed
> > > >> Operations on data form: reject, acept, list, enter
> > > >> Triples of permissions:
> > > >> admin, operator; reject, accept; applied
> > > >> auditor, operator; list; _
> > > >> operator; enter; dirty
>
> > > >> The additional question beside checking permission is:
> > > >> What are operations avaiable for given role and given state of entity
>
> > > >> Any thoughts? Maybe core.logic? It seems that I know its purpose but
> > > >> don't know how to use it.
> > > >> Thanks in advance.
>
> > > >> --
> > > >> You received this message because you are subscribed to the Google
> > > >> Groups "Clojure" group.
> > > >> To post to this group, send email to clojure@googlegroups.com
> > > >> Note that 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 e

Re: Solving this with logic programing

2011-11-05 Thread Michael Jaaka

Btw. Is there any fine tutorial for core.logic? By fine I mean
something like learn haskell for great good.

On 5 Lis, 20:26, Michael Jaaka  wrote:
> Now is ok, easy to grasp. How the lein dep declaration and clj import
> looks?
> Thank you both.
>
> On 5 Lis, 20:11, David Nolen  wrote:
>
>
>
>
>
>
>
> > I would probably write the code like this:
>
> > (defrel permission role op state)
>
> > (defn add-permision [roles ops states]
> >   (doseq [r roles o ops s states]
> >     (fact permission r o s)))
>
> > (add-permision #{:admin :operator} #{:reject :accept} #{:applied})
>
> > (defn permissiono [role op state]
> >     (run* [q]
> >       (permission role op state)
> >       (== q {:role role :op op :state state})))
>
> > (permissiono :admin (lvar) (lvar))
>
> > ;; ({:role :admin, :op :reject, :state :applied}
> > ;;  {:role :admin, :op :accept, :state :applied})
>
> > We can use (lvar) for wildcards. If nothing can satisfy the query you'll
> > get back an empty sequences.
>
> > What in particular do you find unsatisfactory about this interface?
>
> > On Sat, Nov 5, 2011 at 2:46 PM, Michael Jaaka
> > wrote:
>
> > > Thanks, it gave me insight into that framework.
> > > Unfortunately it doesn't look friendly in usage.
> > > Looks like there is a place for a clojure lib or wrapper around
> > > core.logic.
> > > It would be nice if it could answer to questions also in terms of
> > > truth.
>
> > > On 5 Lis, 18:24, Ambrose Bonnaire-Sergeant
> > >  wrote:
> > > > I gave the wildcard requirement a bit of thought, no inspiration at the
> > > > moment.
>
> > > > Maybe someone else can suggest a strategy.
>
> > > > Ambrose
>
> > > > On Sun, Nov 6, 2011 at 1:14 AM, Ambrose Bonnaire-Sergeant <
>
> > > > abonnaireserge...@gmail.com> wrote:
> > > > > Hey Michael,
>
> > > > > Here's a solution using core.logic.
>
> > > > > ;; We can define a "permission" relation with "defrel".
>
> > > > > (defrel permission roles ops state)
>
> > > > > ;; and a helper function to add each combination of permissions
>
> > > > > (defn add-permision [roles ops states]
> > > > >   (for [r roles
> > > > >         o ops
> > > > >         s states]
> > > > >     (fact permission r o s)))
>
> > > > > ;; Here is your first example
>
> > > > > (add-permision #{:admin :operator} #{:reject :accept} #{:applied})
>
> > > > > ;; Now lets ask what are the permissions for the :admin role
>
> > > > > logic-introduction.perm=> (run* [q]
> > > > >                                 (fresh [ops states]
> > > > >                                        (permission :admin ops states)
> > > > >                                        (== q [ops states])))
> > > > > ([:reject :applied] [:accept :applied])
>
> > > > > ;; Ask what permissions either a :admin or :operator role has
>
> > > > > logic-introduction.perm=> (run* [q]
> > > > >                                 (fresh [role ops states]
> > > > >                                        (conde
> > > > >                                          ((== role :admin))
> > > > >                                          ((== role :operator)))
> > > > >                                        (== q [ops states])
> > > > >                                        (permission role ops states)))
> > > > > ([:reject :applied] [:accept :applied] [:reject :applied] [:accept
> > > > > :applied])
>
> > > > > Thanks,
> > > > > Ambrose
>
> > > > > On Sun, Nov 6, 2011 at 12:51 AM, Michael Jaaka <
> > > > > michael.ja...@googlemail.com> wrote:
>
> > > > >> Hi,
>
> > > > >> I would like to use logic programing to describe permissions. The
> > > > >> definition is
>
> > > > >> We have set of triples which looks like:
> > > > >> Set of roles; set of operations; set of states
>
> > > > >> Triples are defined in scope of some entity with states, wildcard is
> > > > >> defined with _
>
> > > > >> All I need is to answer on some operation invocation if given user
> > > > >> with his role is able to execute that operation for particular entity
> > > > >> which is in one of its states
>
> > > > >> Example:
> > > > >> Roles: admin, operator, auditor
> > > > >> Entity: data form with states dirty, applied, rejected, executed
> > > > >> Operations on data form: reject, acept, list, enter
> > > > >> Triples of permissions:
> > > > >> admin, operator; reject, accept; applied
> > > > >> auditor, operator; list; _
> > > > >> operator; enter; dirty
>
> > > > >> The additional question beside checking permission is:
> > > > >> What are operations avaiable for given role and given state of entity
>
> > > > >> Any thoughts? Maybe core.logic? It seems that I know its purpose but
> > > > >> don't know how to use it.
> > > > >> Thanks in advance.
>
> > > > >> --
> > > > >> You received this message because you are subscribed to the Google
> > > > >> Groups "Clojure" group.
> > > > >> To post to this group, send email to clojure@googlegroups.com
> > > > >> Note that posts from new members are moderated - please be patient
> > > with
> > > > >> your first post.

Re: Solving this with logic programing

2011-11-05 Thread David Nolen
There's nothing like a Learn You A core.logic, but Ambrose and Ryan
Senior's tutorials are pretty great.

https://github.com/frenchy64/Logic-Starter/wiki
http://objectcommando.com/

David

On Sat, Nov 5, 2011 at 3:34 PM, Michael Jaaka
wrote:

>
> Btw. Is there any fine tutorial for core.logic? By fine I mean
> something like learn haskell for great good.
>
> On 5 Lis, 20:26, Michael Jaaka  wrote:
> > Now is ok, easy to grasp. How the lein dep declaration and clj import
> > looks?
> > Thank you both.
> >
> > On 5 Lis, 20:11, David Nolen  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > I would probably write the code like this:
> >
> > > (defrel permission role op state)
> >
> > > (defn add-permision [roles ops states]
> > >   (doseq [r roles o ops s states]
> > > (fact permission r o s)))
> >
> > > (add-permision #{:admin :operator} #{:reject :accept} #{:applied})
> >
> > > (defn permissiono [role op state]
> > > (run* [q]
> > >   (permission role op state)
> > >   (== q {:role role :op op :state state})))
> >
> > > (permissiono :admin (lvar) (lvar))
> >
> > > ;; ({:role :admin, :op :reject, :state :applied}
> > > ;;  {:role :admin, :op :accept, :state :applied})
> >
> > > We can use (lvar) for wildcards. If nothing can satisfy the query
> you'll
> > > get back an empty sequences.
> >
> > > What in particular do you find unsatisfactory about this interface?
> >
> > > On Sat, Nov 5, 2011 at 2:46 PM, Michael Jaaka
> > > wrote:
> >
> > > > Thanks, it gave me insight into that framework.
> > > > Unfortunately it doesn't look friendly in usage.
> > > > Looks like there is a place for a clojure lib or wrapper around
> > > > core.logic.
> > > > It would be nice if it could answer to questions also in terms of
> > > > truth.
> >
> > > > On 5 Lis, 18:24, Ambrose Bonnaire-Sergeant
> > > >  wrote:
> > > > > I gave the wildcard requirement a bit of thought, no inspiration
> at the
> > > > > moment.
> >
> > > > > Maybe someone else can suggest a strategy.
> >
> > > > > Ambrose
> >
> > > > > On Sun, Nov 6, 2011 at 1:14 AM, Ambrose Bonnaire-Sergeant <
> >
> > > > > abonnaireserge...@gmail.com> wrote:
> > > > > > Hey Michael,
> >
> > > > > > Here's a solution using core.logic.
> >
> > > > > > ;; We can define a "permission" relation with "defrel".
> >
> > > > > > (defrel permission roles ops state)
> >
> > > > > > ;; and a helper function to add each combination of permissions
> >
> > > > > > (defn add-permision [roles ops states]
> > > > > >   (for [r roles
> > > > > > o ops
> > > > > > s states]
> > > > > > (fact permission r o s)))
> >
> > > > > > ;; Here is your first example
> >
> > > > > > (add-permision #{:admin :operator} #{:reject :accept}
> #{:applied})
> >
> > > > > > ;; Now lets ask what are the permissions for the :admin role
> >
> > > > > > logic-introduction.perm=> (run* [q]
> > > > > > (fresh [ops states]
> > > > > >(permission :admin ops
> states)
> > > > > >(== q [ops states])))
> > > > > > ([:reject :applied] [:accept :applied])
> >
> > > > > > ;; Ask what permissions either a :admin or :operator role has
> >
> > > > > > logic-introduction.perm=> (run* [q]
> > > > > > (fresh [role ops states]
> > > > > >(conde
> > > > > >  ((== role :admin))
> > > > > >  ((== role :operator)))
> > > > > >(== q [ops states])
> > > > > >(permission role ops
> states)))
> > > > > > ([:reject :applied] [:accept :applied] [:reject :applied]
> [:accept
> > > > > > :applied])
> >
> > > > > > Thanks,
> > > > > > Ambrose
> >
> > > > > > On Sun, Nov 6, 2011 at 12:51 AM, Michael Jaaka <
> > > > > > michael.ja...@googlemail.com> wrote:
> >
> > > > > >> Hi,
> >
> > > > > >> I would like to use logic programing to describe permissions.
> The
> > > > > >> definition is
> >
> > > > > >> We have set of triples which looks like:
> > > > > >> Set of roles; set of operations; set of states
> >
> > > > > >> Triples are defined in scope of some entity with states,
> wildcard is
> > > > > >> defined with _
> >
> > > > > >> All I need is to answer on some operation invocation if given
> user
> > > > > >> with his role is able to execute that operation for particular
> entity
> > > > > >> which is in one of its states
> >
> > > > > >> Example:
> > > > > >> Roles: admin, operator, auditor
> > > > > >> Entity: data form with states dirty, applied, rejected, executed
> > > > > >> Operations on data form: reject, acept, list, enter
> > > > > >> Triples of permissions:
> > > > > >> admin, operator; reject, accept; applied
> > > > > >> auditor, operator; list; _
> > > > > >> operator; enter; dirty
> >
> > > > > >> The additional question beside checking permission is:
> > > > > >> What

Re: get all record instances

2011-11-05 Thread Mark Derricutt
I think Colin's record may be more detailed that just a key/value, he
mentioned 'simplified definitions' so I'm guessing there things elided from
the post.

-- 
"Great artists are extremely selfish and arrogant things" — Steven Wilson,
Porcupine Tree


On Sun, Nov 6, 2011 at 6:03 AM, gaz jones  wrote:

> could you not just use a 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: A question on deftest- macro.

2011-11-05 Thread Phil Hagelberg
On Sat, Nov 5, 2011 at 6:57 AM, Young Kim  wrote:
> The unexpected result was that the message "Ran 5 tests containing 8
> assertions".
>
> The expected message was that "Ran 3 tests containing 4 assertions",
> because of two dertest- macros in my test code.
>
> How can I block the execution of the two private deftest- macros in my
> test code?

Just use defn instead of deftest-. There's no reason calls to "is"
can't occur in regular function bodies.

-Phil

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


Re: Clojure Conj extracurricular activities spreadsheet

2011-11-05 Thread daly
What times are available?
How can I choose a time for the literate session?

Tim Daly

On Sat, 2011-11-05 at 10:37 -0400, Doug South wrote:
> On 04/11/2011, at 9:16 PM, Michael Fogus  wrote:
> 
> >> Any thoughts about when / where these events can take place?
> > 
> > At this point it would be great if a Conj-planning heavyweight could
> > step in and provide some additional ideas... although solutions would
> > be great too.  :-)
> 
> According to the conference schedule the conference room is available until 
> 11pm on Thursday. I don't know how big the room is, but as long as the 
> Overtone folks don't get too loud ;), that might be a good place and time to 
> have a mini open conference. As long as all the people involved take 
> responsibility for returning the room to it's "conference state" at the end 
> of the night, that might work well?
> 
> Regards,
> Doug
> 
> Sent from my iPhone
> 


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


Re: get all record instances

2011-11-05 Thread Colin Taylor
Actually that does seem the most idiomatic approach

(def sources
   {:bcc source("bbc.. ),
:google source("),
   }

(defn all-sources []

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


Re: get all record instances

2011-11-05 Thread Colin Taylor
Actually that does seem the most idiomatic approach

(def sources
  {:bcc source("bbc.. ),
   :google source("),
  }

(defn all-sources []
  (vals sources))

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that 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 as scripting language in a Java Application

2011-11-05 Thread Tal Liron
I'll plug Scripturian here, a library I wrote that has very good 
thread-aware support for embedding Clojure, as well as other JVM languages 
(JavaScript, Python, Ruby, PHP, Groovy):

http://threecrickets.com/scripturian/

I just recently wrote a detailed tutorial for it, which was missing for a 
long time.

Stdout redirection is fully supported, as well as a sophisticated 
"text-with-scriptlets" mode, very useful for templating.

Even if you don't want to use Scripturian, its source code will show you a 
few examples of how to access Clojure's RT and bindings from within Java. 
It's ... not trivial, to say the least.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that 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 Conj extracurricular activities spreadsheet

2011-11-05 Thread Christopher Redinger
On Friday, November 4, 2011 9:16:08 PM UTC-4, Fogus wrote:
>
> At this point it would be great if a Conj-planning heavyweight could
> step in and provide some additional ideas... although solutions would
> be great too.  :-)
>

Oh, I guess that's me.

See the 
floorplanfor
 reference.

We have the Oak Forest ballroom until midnight on Thursday and Friday and 
until 5pm on Saturday. This room holds 300 people. Since this is the main 
conference room, we would need it back in the same setup when the room is 
locked up at midnight that we need it when it is unlocked the next morning. 

We have the Atrium area, which is setup to hold around 50 people at round 
tables, until midnight on Thursday and Friday and noon on Saturday. This is 
designated as our "game area." So, Go should definitely be happening here. 
This is an open area, and will feel more publicly accessible, passersby 
will possibly stop to see what's going on if it looks interesting.

We have the Presidents Boardroom until midnight on Thursday and Friday and 
6pm on Saturday. This is a small room that can hold about 20. So, smaller 
groups should use this room.

There are also smaller public spaces round the ballroom where people could 
meet up for some organized hack sessions, etc.

But, keep in mind that things are pretty heavily scheduled during this time 
as well. The plan is to have lightning talks in the ballroom on Thursday 
evening. Of course, many of those can be combined with the planning that's 
happening here. And Friday night, we have the party at the ArtSpace.

Beyond that ... Chas said something about using his room when I mentioned I 
was wondering when and where all of these things were going to take place. 
I'm going to have to assume everyone that wants to organize some kind of 
activity is willing to do something similar. :)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that 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 Conj extracurricular activities spreadsheet

2011-11-05 Thread daly
So, to be specific, lets assume that the literate programming
session will meet in the presidential boardroom at 7pm on
wednesday evening. It will likely be a small group and I don't
expect it to take long. It is only scheduled for 15 minutes.

Tim Daly


On Sat, 2011-11-05 at 19:10 -0700, Christopher Redinger wrote:
> On Friday, November 4, 2011 9:16:08 PM UTC-4, Fogus wrote:
> At this point it would be great if a Conj-planning heavyweight
> could
> step in and provide some additional ideas... although
> solutions would
> be great too.  :-)
> 
> 
> 
> 
> Oh, I guess that's me.
> 
> 
> See the floorplan for reference.
> 
> 
> We have the Oak Forest ballroom until midnight on Thursday and Friday
> and until 5pm on Saturday. This room holds 300 people. Since this is
> the main conference room, we would need it back in the same setup when
> the room is locked up at midnight that we need it when it is unlocked
> the next morning. 
> 
> 
> We have the Atrium area, which is setup to hold around 50 people at
> round tables, until midnight on Thursday and Friday and noon on
> Saturday. This is designated as our "game area." So, Go should
> definitely be happening here. This is an open area, and will feel more
> publicly accessible, passersby will possibly stop to see what's going
> on if it looks interesting.
> 
> 
> We have the Presidents Boardroom until midnight on Thursday and Friday
> and 6pm on Saturday. This is a small room that can hold about 20. So,
> smaller groups should use this room.
> 
> 
> There are also smaller public spaces round the ballroom where people
> could meet up for some organized hack sessions, etc.
> 
> 
> But, keep in mind that things are pretty heavily scheduled during this
> time as well. The plan is to have lightning talks in the ballroom on
> Thursday evening. Of course, many of those can be combined with the
> planning that's happening here. And Friday night, we have the party at
> the ArtSpace.
> 
> 
> Beyond that ... Chas said something about using his room when I
> mentioned I was wondering when and where all of these things were
> going to take place. I'm going to have to assume everyone that wants
> to organize some kind of activity is willing to do something
> similar. :)
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that 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


Newbie question on OO/records

2011-11-05 Thread stevelewis
Okay, I'm trying to understand records. I read this article:
http://freegeek.in/blog/2010/05/clojure-protocols-datatypes-a-sneak-peek/
(Clojure Protocols & Datatypes - A sneak peek by Baishampayan Ghose. I
found it helpful, but the usage of datatypes and protocols looks/feels
very object-oriented to me. Am I wrong? Is it just because the
function comes before the record instance?

(fly hummingbird)

As opposed to calling:

hummingbird.fly() in a standard OO language.

Thanks for any insight.
Steve

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that 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 on OO/records

2011-11-05 Thread Matt Hoyt
Protocols are a way to achieve polymorphism.  Clojure protocols are similar to 
Haskell types classes. 

Here is a video that explains clojure protocols: http://vimeo.com/11236603
 
Matt Hoyt



From: stevelewis 
To: Clojure 
Sent: Saturday, November 5, 2011 6:40 PM
Subject: Newbie question on OO/records

Okay, I'm trying to understand records. I read this article:
http://freegeek.in/blog/2010/05/clojure-protocols-datatypes-a-sneak-peek/
(Clojure Protocols & Datatypes - A sneak peek by Baishampayan Ghose. I
found it helpful, but the usage of datatypes and protocols looks/feels
very object-oriented to me. Am I wrong? Is it just because the
function comes before the record instance?

(fly hummingbird)

As opposed to calling:

hummingbird.fly() in a standard OO language.

Thanks for any insight.
Steve

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

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

Re: Clojure Conj extracurricular activities spreadsheet

2011-11-05 Thread Chas Emerick

On Nov 5, 2011, at 10:10 PM, Christopher Redinger wrote:

> On Friday, November 4, 2011 9:16:08 PM UTC-4, Fogus wrote:
> At this point it would be great if a Conj-planning heavyweight could
> step in and provide some additional ideas... although solutions would
> be great too.  :-)
> 
> 
> Oh, I guess that's me.
> 
> See the floorplan for reference.
> 
> We have the Oak Forest ballroom until midnight on Thursday and Friday and 
> until 5pm on Saturday. This room holds 300 people. Since this is the main 
> conference room, we would need it back in the same setup when the room is 
> locked up at midnight that we need it when it is unlocked the next morning. 
> 
> We have the Atrium area, which is setup to hold around 50 people at round 
> tables, until midnight on Thursday and Friday and noon on Saturday. This is 
> designated as our "game area." So, Go should definitely be happening here. 
> This is an open area, and will feel more publicly accessible, passersby will 
> possibly stop to see what's going on if it looks interesting.
> 
> We have the Presidents Boardroom until midnight on Thursday and Friday and 
> 6pm on Saturday. This is a small room that can hold about 20. So, smaller 
> groups should use this room.
> 
> There are also smaller public spaces round the ballroom where people could 
> meet up for some organized hack sessions, etc.
> 
> But, keep in mind that things are pretty heavily scheduled during this time 
> as well. The plan is to have lightning talks in the ballroom on Thursday 
> evening. Of course, many of those can be combined with the planning that's 
> happening here. And Friday night, we have the party at the ArtSpace.
> 
> Beyond that ... Chas said something about using his room when I mentioned I 
> was wondering when and where all of these things were going to take place. 
> I'm going to have to assume everyone that wants to organize some kind of 
> activity is willing to do something similar. :)

Nice, thanks for the pointer and details.

Hrm, I *did* say that, didn't I? :-P  There's surely bar areas people can 
overtake, etc., but yeah, last resorts call for desperate measures.

- Chas

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that 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 Conj extracurricular activities spreadsheet

2011-11-05 Thread Phil Hagelberg
On Fri, Nov 4, 2011 at 6:16 PM, Michael Fogus  wrote:
>> Any thoughts about when / where these events can take place?
>
> At this point it would be great if a Conj-planning heavyweight could
> step in and provide some additional ideas... although solutions would
> be great too.  :-)

For what it's worth, the Heroku Drinkup is turning into Drinks at the
Game Room on Wednesday sponsored by Heroku, so find me or other Heroku
folks if you're coming in early for a drink ticket.

-Phil

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


Re: Newbie question on OO/records

2011-11-05 Thread Baishampayan Ghose
> Okay, I'm trying to understand records. I read this article:
> http://freegeek.in/blog/2010/05/clojure-protocols-datatypes-a-sneak-peek/
> (Clojure Protocols & Datatypes - A sneak peek by Baishampayan Ghose. I
> found it helpful, but the usage of datatypes and protocols looks/feels
> very object-oriented to me. Am I wrong? Is it just because the
> function comes before the record instance?
>
> (fly hummingbird)
>
> As opposed to calling:
>
> hummingbird.fly() in a standard OO language.

Records & Protocols are indeed a way of achieving polymorphism and is
quite similar to class-based single dispatch found in Java, etc. Thus
the calling conventions can look quite familiar.

Having said that, records & protocols are fundamentally different from
class based OO since unlike classes, records & protocols don't
complect state and abstractions.

In your standard OO example, the state as well as the abstraction
method implementations "reside" in the hummingbird object. In case of
Clojure the state is provided by the record/datatype and the method
implementations are provided by the protocols which the record type
chooses to extend.

There is nothing wrong with OO, as long as we are not conflating
orthogonal semantics.

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.com

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