Re: [ANN] Clojure 1.10.0-alpha7

2018-09-07 Thread Mamun
After update to version "1.10.0-alpha7", I found pedestal/log is broken 

pedestal version 0.5.4. 

Here is details info in bellow 

(ns io.pedestal.log 
"Logging via slf4j. Each logging level is a macro: trace, debug, 
info, warn, and error. Each namespace gets its own Logger. Arguments 
are key-value pairs, which will be printed as with 'pr'. The special 
key :exception should have a java.lang.Throwable as its value, and 
will be passed separately to the underlying logging API. 
One can override the logger via JVM or ENVAR settings." 
(:require clojure.string) 
(:import (org.slf4j Logger 
LoggerFactory 
MDC) 
(org.slf4j.spi MDCAdapter) 
(com.codahale.metrics MetricRegistry 
Gauge Counter Histogram Meter 
Slf4jReporter) 
(com.codahale.metrics.jmx JmxReporter) 
(io.opentracing Scope 
Span 
SpanContext 
Tracer 
Tracer$SpanBuilder) 
(io.opentracing.log.Fields) 
(io.opentracing.util GlobalTracer) 
(java.util Map) 
(java.util.concurrent TimeUnit) 
(clojure.lang IFn)))



Error msg 

Syntax error macroexpanding clojure.core/ns at (io/pedestal/log.clj:13:1). 
Cause: Call to clojure.core/ns did not conform to spec.
() - failed: Insufficient input at: [:ns-clauses :import :classes 
:package-list :classes] spec: :clojure.core.specs.alpha/package-list
(io.opentracing.log.Fields) - failed: simple-symbol? at: [:ns-clauses 
:import :classes :class] spec: :clojure.core.specs.alpha/ns-import
:import - failed: #{:refer-clojure} at: [:ns-clauses :refer-clojure 
:clause] spec: :clojure.core.specs.alpha/ns-refer-clojure
:import - failed: #{:require} at: [:ns-clauses :require :clause] spec: 
:clojure.core.specs.alpha/ns-require
:import - failed: #{:use} at: [:ns-clauses :use :clause] spec: 
:clojure.core.specs.alpha/ns-use
:import - failed: #{:refer} at: [:ns-clauses :refer :clause] spec: 
:clojure.core.specs.alpha/ns-refer
:import - failed: #{:load} at: [:ns-clauses :load :clause] spec: 
:clojure.core.specs.alpha/ns-load
:import - failed: #{:gen-class} at: [:ns-clauses :gen-class :clause] spec: 
:clojure.core.specs.alpha/ns-gen-class



Br,
Mamun



On Wednesday, September 5, 2018 at 2:39:36 PM UTC+2, stuart@gmail.com 
wrote:
>
> deps.edn dependency:
>
>   org.clojure/clojure {:mvn/version "1.10.0-alpha7"}
>
> 1.10.0-alpha7 includes the following changes since 1.10.0-alpha6:
>
>- Update deps to latest spec.alpha (0.2.176) and core.specs.alpha 
>(0.2.44)
>- CLJ-2373 <https://dev.clojure.org/jira/browse/CLJ-2373> - categorize 
>and overhaul printing of exception messages at REPL
>- CLJ-1279 <https://dev.clojure.org/jira/browse/CLJ-1279> - report 
>correct arity count for function arity errors inside macros
>- CLJ-2386 <https://dev.clojure.org/jira/browse/CLJ-2386> - omit 
>ex-info construction stack frames
>- CLJ-2394 <https://dev.clojure.org/jira/browse/CLJ-2394> - warn in 
>pst that stack trace for syntax error failed before execution
>- CLJ-2396 <https://dev.clojure.org/jira/browse/CLJ-2396> - omit :in 
>clauses when printing spec function errors if using default explain printer
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] Clojure 1.9.0 is now available!

2017-12-26 Thread Mamun
Thanks

It is working with (defmethod mycomp ~m [~'_] ~m))
_ is also clojure valid symbol identifier. I miss that point.


Br,
Mamun


On Tuesday, December 26, 2017 at 11:59:23 PM UTC+1, Gary Verhaegen wrote:
>
> The spec is correct; your code is wrong and I don't know how you got your 
> expansion there.
>
> $ lein try org.clojure/clojure 1.9.0
> nREPL server started on port 55018 on host 127.0.0.1 - nrepl://
> 127.0.0.1:55018
> REPL-y 0.3.7, nREPL 0.2.12
> Clojure 1.8.0
> Java HotSpot(TM) 64-Bit Server VM 1.8.0_144-b01
> Docs: (doc function-name-here)
>   (find-doc "part-of-name-here")
>   Source: (source function-name-here)
>  Javadoc: (javadoc java-object-or-class-here)
> Exit: Control+D or (exit) or (quit)
>  Results: Stored in vars *1, *2, *3, an exception in *e
>
> user=> (defmulti mycomp (fn [v] v))
> #'user/mycomp
> user=> (defmacro defcomp [m]
>   #_=>   `(defmethod mycomp ~m
>   #_=>  [_]
>   #_=>  ~m
>   #_=> )
>   #_=>   )
> #'user/defcomp
> user=> (defcomp :test)
>
> CompilerException java.lang.RuntimeException: Can't use qualified name as 
> parameter: user/_, compiling:(null:1:1)
> user=> (macroexpand '(defcomp test))
> (. user/mycomp clojure.core/addMethod test (clojure.core/fn [user/_] test))
> user=>
>
> The problem is that you have not protected the _, so it gets expanded to 
> the local namespace (user/_ in my case here, com.mxsys.psql.component/_ 
> in yours). You want:
>
> user=> (defmacro defcomp [m] `(defmethod mycomp ~m [~'_] ~m))
> #'user/defcomp
> user=> (defcomp :test)
> #multifn[mycomp 0x545609d8]
> user=> (macroexpand '(defcomp :test))
> (. user/mycomp clojure.core/addMethod :test (clojure.core/fn [_] :test))
> user=>
>
> Notice how the underscore is escaped as ~'_ to escape from the syntax 
> quote and place a literal underscore symbol.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] Clojure 1.9.0 is now available!

2017-12-26 Thread Mamun
Congratulation. I am getting one problem for defmacro spec with defmethod. 
Here it is 

(defmulti mycomp (fn [v] v))
(defmacro defcomp [m]
  `(defmethod mycomp ~m
 [_]
 ~m
)
  )

(defcomp :test) ;; Throwing exception 

;; Expand macro
(defmethod mycomp :test [_] :test)
;; it is working 




Here is error details 

  Call to clojure.core/fn did not conform to spec: In: [0 0] val:
   (com.mxsys.psql.component/_) fails spec: 
:clojure.core.specs.alpha/arg-list
   at: [:args :bs :arity-1 :args] predicate: (cat :args (*
   :clojure.core.specs.alpha/binding-form) :varargs (? (cat :amp #{(quote 
&)}
   :form :clojure.core.specs.alpha/binding-form))), Extra input In: [0 0] 
val:
   com.mxsys.psql.component/_ fails spec: 
:clojure.core.specs.alpha/arg-list at:
   [:args :bs :arity-n :args] predicate: vector?

Br,
Mamun






On Friday, December 8, 2017 at 8:35:39 PM UTC+1, Alex Miller wrote:
>
> Clojure 1.9 is now available!
>
>
> Clojure 1.9 introduces two major new features: integration with spec and 
> command line tools.
>
>
> spec (rationale <https://clojure.org/about/spec>, guide 
> <https://clojure.org/guides/spec>) is a library for describing the 
> structure of data and functions with support for:
>
>- Validation
>- Error reporting
>- Destructuring
>- Instrumentation
>- Test-data generation
>- Generative test generation
>- Documentation
>
> Clojure integrates spec via two new libraries (still in alpha):
>
>- spec.alpha <https://github.com/clojure/spec.alpha> - spec 
>implementation
>- core.specs.alpha <https://github.com/clojure/core.specs.alpha> - 
>specifications for Clojure itself
>
> This modularization facilitates refinement of spec separate from the 
> Clojure release cycle.
>
> The command line tools (guide <https://clojure.org/guides/deps_and_cli>, 
> reference <https://clojure.org/reference/deps_and_cli>) provide:
>
>- Quick and easy install
>- Clojure REPL and runner
>- Use of Maven and local dependencies
>- A functional API for classpath management (tools.deps.alpha 
><https://github.com/clojure/tools.deps.alpha>)
>
> The installer is available for Mac developers in brew, for Linux users in 
> a script, and for more platforms in the future.
>
> For more information, see the complete list 
> <https://github.com/clojure/clojure/blob/master/changes.md> of all 
> changes in Clojure 1.9 for more details.
>
>
> *Contributors*
>
>
> Thanks to all of the community members who contributed to Clojure 1.9 
> (first time contributors in bold):
>
>
>- *Adam Clements*
>- Andy Fingerhut
>- Brandon Bloom
>- *Cameron Desautels*
>- *Chad Taylor*
>- Chris Houser
>- *David Bürgin*
>- *Eli Lindsey*
>- *Gerrit Jansen Van Vuuren*
>- Ghadi Shayban
>- *Greg Leppert*
>- *Jason Whitlark*
>- *Johan Mena*
>- Jozef Wagner
>- *Lee Yen-Chin*
>- *Matthew Boston*
>- Michael Blume
>- Michał Marczyk
>- Nicola Mometto
>- *Ruslan Al-Fakikh*
>- *Steffen Dienst*
>- Steve Miner
>- *Yegor Timoshenko*
>- *Zhuang XiaoDan*
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Clojure spec keys is considering all key within namespace although it is not defined

2017-06-28 Thread Mamun
Hi All,

Clojure spec keys is considering all key within namespace although it is 
not defined.

Here is an example 

(s/def :person/fname string?)
(s/def :person/lname string?)
(s/def :person/id int?)

 ;;With only fname and lname
(s/def :app/person (s/keys :req [:person/fname :person/lname]))

;;Success
(s/explain-str :app/person
   {:person/lname "Abdullah"
:person/fname "Mamun"} )

;;Success
(s/explain-str :app/person
   {:person/lname "Abdullah"
    :person/fname "Mamun"
:id "123"} )

;;fail with namespace id
(s/explain-str :app/person
   {:person/lname "Abdullah"
:person/fname "Mamun"
:person/id "1234"})


Is it bug or am I doing something wrong here?

Br,
Mamun

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] spec-model 0.1.0 generate spec with convention

2016-11-27 Thread Mamun
Please find github link in bellow 
https://github.com/Mamun/spec-model

Br,
Mamun

On Sunday, November 27, 2016 at 11:37:30 PM UTC+1, Mamun wrote:
>
>
>
> It is very common that application needs different format of data, 
> sometime only entity, sometimes with entity type or list of entity. As an 
> example 
>
> Business entity 
> Dept {dept-name,id } has many employee {empl-name, id}. 
>
>
> As entity : {:dept-name "IT"}
> List of entity  [{:dept-name "IT"}]
> Domain type {:dept {:dept-name "IT"}}
> List of domain type [{:dept {:dept-name "IT"}}]
>
>
> Additionally you need to think about namespace qualified key, unqualified 
> key and string conformation. In the end to define spec registry key will be 
> challenging that will be understandable to all team member within project.
>
> spec-model is solution for it. Like UML tools, define business model as 
> data. spec-model will generate spec for it.
>
> Br,
> Mamun
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] spec-model 0.1.0 generate spec with convention

2016-11-27 Thread Mamun


It is very common that application needs different format of data, sometime 
only entity, sometimes with entity type or list of entity. As an example 

Business entity 
Dept {dept-name,id } has many employee {empl-name, id}. 


As entity : {:dept-name "IT"}
List of entity  [{:dept-name "IT"}]
Domain type {:dept {:dept-name "IT"}}
List of domain type [{:dept {:dept-name "IT"}}]


Additionally you need to think about namespace qualified key, unqualified 
key and string conformation. In the end to define spec registry key will be 
challenging that will be understandable to all team member within project.

spec-model is solution for it. Like UML tools, define business model as 
data. spec-model will generate spec for it.

Br,
Mamun

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Is there any way to pass clojure spec conform value to next spec?

2016-11-18 Thread Mamun
HI All

Take an example in bellow 

(defn x-int? [x]
  (cond
(integer? x) x
(string? x) (try
  (Integer/parseInt x)
  (catch Exception e
:clojure.spec/invalid))
:else :clojure.spec/invalid))



(s/explain (and (s/conformer x-int?) (s/int-in 10 15)) "12")  ;; Failed 
(s/explain (and (s/conformer x-int?) (s/int-in 10 15))  11  ) ;;  Passed

In here, explain does not work because of and. Is there any way to pass 
conform value to next spec? 

Br,
Mamun

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: clojure.spec - Using :pre conditions (or not)?

2016-09-15 Thread Mamun

When function is throwing exception because of argument. I would prefer to 
throw IllegalArgumentException not AssertionError. 


(defn check [type data]
  (if (sp/valid? type data)
true
(throw (IllegalArgumentException. (sp/explain type data)


Br,
Mamun


On Friday, September 16, 2016 at 7:20:53 AM UTC+2, joakim.t...@nova.com 
wrote:
>
> I came up with this solution:
>
> (ns spec-test.core
>   (:require [clojure.spec :as s]))
>
> (s/def :user/name string?)
> (s/def :common/user (s/keys :req [:user/name]))
>
> ;; with this little helper function...
> (defn check [type data]
>   (if (s/valid? type data)
> true
> (throw (AssertionError. (s/explain type data)
>
> ;; I can use it in my :pre condition
> (defn aname [user]
>   {:pre [(check :common/user user)]}
>   (-> user :user/name))
>
> ;; when I call name with an illegal arguement...
> (aname {:x "Elon"})
>
> ;; ...it not fails and returns a better error message:
> CompilerException java.lang.AssertionError: null, 
> compiling:(/Users/joakimtengstrand/IdeaProjects/spec-test/src/spec_test/core.clj:19:1)
> val: {:x "Elon"} fails spec: :common/user predicate: (contains? % :user/name)
>
>
> With this solution I don't need to enable assertions, and the code is neat 
> and less verbose!
>
> /Joakim
>
> On Thursday, September 15, 2016 at 3:11:32 PM UTC+2, Shantanu Kumar wrote:
>>
>> Hi Joakim,
>>
>> You might be interested in Paul Stadig's library 
>> https://github.com/pjstadig/assertions that leverages Java's `-ea` 
>> (enable-assertions, which you may want to keep enabled in dev) command-line 
>> flag. If you have a bunch of things together to assert, you may want to use 
>> the `when-assert` macro for wholesale optimization: 
>> https://github.com/pjstadig/assertions/blob/0.2.0/src/pjstadig/assertions.clj#L13
>>
>>
>> Shantanu
>>
>> On Thursday, 15 September 2016 16:50:17 UTC+5:30, joakim.t...@nova.com 
>> wrote:
>>>
>>> Ok, thanks!
>>>
>>> In the Java world, the assertions is also something that need to be turn 
>>> on explicitly.
>>> In that sence, they are kind of not mandatory to be executed (or at 
>>> least signals that to the reader of the code).
>>>
>>> I would be happier if you guys could add another method, that I can use 
>>> in my :pre conditions, that leverage
>>> the same amount of details in the error messages, but that is always 
>>> "turned on".
>>>
>>> In the meanwhile, I will use s/assert ;-)
>>>
>>> BR,
>>> Joakim Tengstrand
>>>
>>>
>>> On Wednesday, 14 September 2016 15:59:09 UTC+2, Alex Miller wrote:
>>>>
>>>> Another option that has been added since the guide was written is 
>>>> s/assert which seems closer to what you're suggesting.
>>>>
>>>> (defn name [user]
>>>>   {:pre [(s/assert :common/user user)]}
>>>>   (-> user :user/name))
>>>>
>>>> ;; need to enable assertion checking - this can also be enabled 
>>>> globally with system property clojure.spec.check-asserts
>>>> (s/check-asserts true)
>>>>
>>>> (name {:user/name "Elon"})
>>>> "Elon"
>>>>
>>>> (name {:x "Elon"})
>>>> ExceptionInfo Spec assertion failed
>>>> val: {:x "Elon"} fails predicate: (contains? % :user/name)
>>>> :clojure.spec/failure  :assertion-failed
>>>>   clojure.core/ex-info (core.clj:4725)
>>>>
>>>> Rather than use it in a precondition, you can also use s/assert 
>>>> directly in the code.
>>>>
>>>> On Wednesday, September 14, 2016 at 7:37:24 AM UTC-5, 
>>>> joakim.t...@nova.com wrote:
>>>>>
>>>>> (ns spec-test.core
>>>>>   (:require [clojure.spec :as s]))
>>>>>
>>>>> (s/def :user/name string?)
>>>>> (s/def :common/user (s/keys :req [:user/name]))
>>>>>
>>>>> ; first version of name (using :pre)
>>>>> (defn name [user]
>>>>>   {:pre [(s/valid? :common/user user)]}
>>>>>   (-> user :user/name))
>>>>>
>>>>> ; This statement works ok and returns "Elon":
>>>>> (name {:user/name "Elon"})
>>>>>
>>>>> ; but this statement...
>>>>> (name {:x "Elon"})
>>>>>
>>>>> ;...will throw

Clojure spec for domain model

2016-09-09 Thread Mamun
Hi All,

I have different type of model in my domain like User, Credit.  I would 
like to define spec of the model in one clj/cljs but not different clj/cljs 
file. Because I don't want to create one clj file for per model. On the 
other hand Clojure namespaces are very similar to Java packages. 
(https://github.com/clojuredocs/guides/blob/master/articles/language/namespaces.md)

Additionally I could not defined same keyword with different predicate in 
one namespace.

So what I did in bellow.


(ns model
  (:require [clojure.spec :as s]
[clojure.walk :as w]))

(defn update-ns
  " "
  [ns-str spec-list]
  (w/postwalk (fn [v]
(if (and (keyword? v)
 (= (namespace v) (str *ns*)))
  (keyword (str ns-str "/" (name v)))
  v)
) spec-list))

(defmacro in-spec
  ""
  [n & content]
  (let [content (update-ns n content)]
`(do
   (clojure.core/in-ns '~(symbol n))
   (clojure.core/refer 'clojure.core)
   (clojure.core/require '[clojure.spec :as ~(symbol 's)])
   ~@content
   nil)))


(in-spec User
  (s/def ::id string?))

(in-spec Credit
  (s/def ::id number?))


(s/valid? :User/id "Musterman")
(s/valid? :Credit/id 12345)
(s/valid? :Credit/id "Error")


Although I am creating namespace here but it is not visible here.
I would like to know Is there any better way to do or any core function 
that I could use here?

Thanks,
Mamun



-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: map/filter/remove etc. change underlying structure

2016-09-09 Thread Mamun
To me, Changing type or order is a lack of facility for basic task. 
In the end comping task is also become more hard. 
Have you tried to use Specter? Why do you not consider Specter lib? 


Br,
Mamun





On Friday, September 9, 2016 at 12:23:37 PM UTC+2, Colin Yates wrote:
>
> Hi all,
>
> So in the spirit of exposing my ignorance to the internet :-), I have just 
> been bitten by a bug due to the behaviour of the core libraries which I 
> find really surprising:
>
> (def v [1 2 3])
> (conj v 4) => [1 2 3 4]
> (conj (map identity v) 4) => (4 1 2 3)
> (conj (remove (constantly false) v) 4) => (4 1 2 3)
> (conj (filter identity v) 4) => (4 1 2 3)
>
> In other words, I was relying on map, remove and filter preserving the 
> semantics (other than laziness) of the structure of the input, give it a 
> vector and you get a vector-like lazy sequence. This turns out not to be 
> the case.
>
> Now, I know there is mapv which returns a vector but why isn't there a 
> removev and a filterv etc.?
>
> What makes it more onerous for me is the fact conj states that its 
> behaviour differs depending on the concrete type, which is great, but how 
> am I supposed to know which concrete type is returned from 
> map|filter|remove? My assumption was it would be semantically equivalent to 
> the input (i.e. a vector in this case).
>
> The reason I have dodged this is because I don't frequently rely on vector 
> semantics but I am surprised this isn't better documented?
>
> Is it me?
>
> Thanks,
>
> 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How does clojure.core quote function work for keyword?

2016-07-26 Thread Mamun
Hi 

How does clojure.core quote function work for keyword? If it is namespace 
keyword then it is displaying with namespace. Is it excepted result?  

(println  (quote a)) 
=> a

(println  (quote :a) )
=> :a

(println  (quote ::a) )
=> :user/a  ;; I am expecting it should display ::a



Br,
Mamun





-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Does clojure.set/rename-keys work with namespace key?

2016-07-22 Thread Mamun
Please skip my last email. It is working. 

Br,
Mamun

On Friday, July 22, 2016 at 11:50:08 AM UTC+2, Mamun wrote:
>
> Hi
>
> Does clojure.set/rename-keys work with namespaced keys? 
>
>  (clojure.set/rename-keys {:fname "Musterman"} {:fname :person/fname})
> => #:person{:fname "Musterman"}
>
>
> Is it expected result? Why namespace as #:person? According to 
> documentation, it should return map. 
>
>
> Clojure version: [org.clojure/clojure "1.9.0-alpha10"]
>
> Br,
> Mamun
>
>
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Does clojure.set/rename-keys work with namespace key?

2016-07-22 Thread Mamun
Hi

Does clojure.set/rename-keys work with namespaced keys? 

 (clojure.set/rename-keys {:fname "Musterman"} {:fname :person/fname})
=> #:person{:fname "Musterman"}


Is it expected result? Why namespace as #:person? According to 
documentation, it should return map. 


Clojure version: [org.clojure/clojure "1.9.0-alpha10"]

Br,
Mamun






-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


clojure.spec merge is excellent, but do you consider dissoc spec for keys?

2016-07-19 Thread Mamun
Hi 

Without dissoc in keys, how to avoid duplicate spec between backend and 
frontend layer?

As an example 

I have backend service where I defined spec like this 

(s/def ::person-spec (s/keys ::req-un [::id ::fname ::lname]))

Here Id is mandatory for some purpose. 

Now application layer I would like to reuse that backend spec but only id. 
Look like now it is not possible as there is no dissoc 

As it is application layer 

(s/def ::person-ui-spec (s/merge (s/keys ::req-un [::channel])
   ::person-spec
   ) )

merge is excellent, as I could reuse exiting spec. But how I dissoc id from 
exiting spec.

Only way is now to do is define again in application layer.

(s/def ::person-ui-spec (s/keys ::req-un [::channel ::fname ::lname]))


Do you consider dissoc in spec for keys?



Br,
Mamun
bnp paribas groups










 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


clojure.spec from returns object instaced of data for every-kv

2016-07-19 Thread Mamun
Hi 

According to documentation of clojure.spec/from, it should return data not 
object. But when I try for every-kv, it is returning object. 


(s/form (s/every-kv keyword? int?))
=>
(clojure.spec/every
 (clojure.spec/tuple keyword? int?)
 :into
 {}
 :clojure.spec/kind-form
 nil
 :clojure.spec/kfn
 #object[t.spec$eval5492$fn__5493 0x1d39ed6f 
"t.spec$eval5492$fn__5493@1d39ed6f"])


But for other it looks ok

(s/form (s/coll-of keyword? ))
=>
 (clojure.spec/every keyword? :clojure.spec/kind-form nil 
:clojure.spec/conform-all true)


(s/form (s/alt :i int? :s string?))
=>
(clojure.spec/alt :i clojure.core/int? :s clojure.core/string?)


Clojure version: [org.clojure/clojure "1.9.0-alpha10"] 


Br,
Mamun


-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


clojure.spec Invalid token error from different namespace when specs are registered with number

2016-06-29 Thread Mamun
Hi,

Invalid token error from different namespace when specs are registered with 
number

Example 

;one.clj

(s/def ::a string?)
(s/def ::1 int?)

::1  ;Ok
::a  ;Ok

;one-test.clj

:one/1  ;; Error
:one/a  ;;Ok

;(gen/sample (s/gen ::1))
;(gen/sample (s/gen ::a))



I am not sure, it is bug or not. But error should display in same namespace 
also. 

Clojure version: [org.clojure/clojure "1.9.0-alpha8"]


Br,
Mamun

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] Clojure 1.9.0-alpha5

2016-06-08 Thread Mamun
Excellent set of new predicates. What about date predicate? 

It would be nice if there are also date predicate as an example in bellow

date?  
date-past?
date-future?



Br,
Mamun




On Tuesday, June 7, 2016 at 7:38:34 PM UTC+2, Alex Miller wrote:
>
> Clojure 1.9.0-alpha5 is now available.
>
> Try it via
>
> - Download:
>  https://repo1.maven.org/maven2/org/clojure/clojure/1.9.0-alpha5 
> <https://repo1.maven.org/maven2/org/clojure/clojure/1.9.0-alpha5>
> - Leiningen: [org.clojure/clojure "1.9.0-alpha5"]
>
> 1.9.0-alpha4 includes the following changes since 1.9.0-alpha4:
>
> Fixes:
> - doc was printing "Spec" when none existed
> - fix ? explain
>
> New predicates in core (all also now have built-in generator support in 
> spec):
> - seqable?
> - boolean?
> - long?, pos-long?, neg-long?, nat-long?
> - double?, bigdec?
> - ident?, simple-ident?, qualified-ident?
> - simple-symbol?, qualified-symbol?
> - simple-keyword?, qualified-keyword?
> - bytes? (for byte[])
> - indexed?
> - inst? (and new inst-ms)
> - uuid?
> - uri?
>
> New in spec:
> - unform - given a spec and a conformed value, returns the unconformed 
> value
> - New preds: long-in-range?, inst-in-range?
> - New specs (with gen support): long-in, inst-in, double-in
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


tiesql - Clojure sql lib to do sql stuff and more

2015-12-11 Thread Mamun
Hi All,

Find link in bellow

https://github.com/Mamun/tie/tree/master/tiesql

Clojurescript/om example 

https://github.com/Mamun/tiesql-om

Still work in progress but look forward to get your feedback.

Br,
Mamun

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Clojure pre assertion functions does not work with keyword?

2014-02-13 Thread Mamun
Hi

I am just testing clojure :pre condition. But look like using keyword?, it 
is not working in clojure 1.5.1. 

(defn check-keyword [v] {:pre [keyword? v]} v)

(defn check-nil [v] {:pre [nil? v]} v)

(check-keyword “sdf”) ;Not throwing exception here

(check-nil nil) ;Throwing exception



Br,

Mamun

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Clojure pre assertion functions does not work with keyword?

2014-02-13 Thread Mamun
HI Ambrose,

Thanks for your reply. But why this one is working?

 (defn check-nil [v]
 {:pre [nil? v]}
  v)

Br,
Mamun


On Thursday, February 13, 2014 11:51:31 AM UTC+1, Ambrose Bonnaire-Sergeant 
wrote:

 Hi Mamun,

 This is the correct syntax (you're missing some parens).

 (defn check-keyword [v] {:pre [(keyword? v)]} v)

 Thanks,
 Ambrose


 On Thu, Feb 13, 2014 at 6:47 PM, Mamun mamu...@gmail.com javascript:wrote:

 Hi

 I am just testing clojure :pre condition. But look like using keyword?, 
 it is not working in clojure 1.5.1. 
  
 (defn check-keyword [v] {:pre [keyword? v]} v)

 (defn check-nil [v] {:pre [nil? v]} v)

 (check-keyword “sdf”) ;Not throwing exception here

 (check-nil nil) ;Throwing exception



 Br,

 Mamun

  -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 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 unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [ANN] Yesql 0.2.1 - Clojure SQL queries rethought.

2013-11-12 Thread Mamun
Hi Kris,

I am not sure about that. On the other hand, it will be boring to write 20 
query in 20 different files. 

Could you please check: 
https://developers.google.com/closure/templates/docs/helloworld_js
Here comment contains meta data for core part. 

Similarly, query'd contain meta data in comment part. Query will be 
identified based on meta data

(def query {:name-of-the-file {:name named-of-the-query :query 
query-body :doc doc}})

Please find sql file example in bellow:

-- {:doc Counts the users in a given country. :name by_controry_code :query 

SELECT count(*) AS count FROM user WHERE country_code = :country_code 

-- }

-- {:doc Counts the users in a given country. :name by_id :query 

SELECT count(*) AS count FROM user WHERE id = :id

-- }


Hi Mamun,


 Hmm...I hadn't planned on it, but I could see it would suit some people's 
 development style. (It could get messy, but so can Clojure namespaces if 
 you're undisciplined. The developer should be allowed to take 
 responsibility.)

 The tricky parts would be:

- How would you delimit the various queries? In a clear, portable way 
that allowed for docstrings? 
- How would you refer to the individual queries? Some kind of 
mandatory '-- NAME: foo-query' syntax?

 Any thoughts?

 Kris

 On Monday, 11 November 2013 14:46:55 UTC, Mamun wrote:

 Hi Kris,

 It's look fine. Is is possible to to add more query in one sql file? I 
 mean- I'd like to create one sql file and store all query on that file.

 BR,
 Mamun



 On Monday, November 11, 2013 2:38:27 PM UTC+1, Kris Jenkins wrote:

 Thanks David, that's nice of you to say. I know exactly what you mean - 
 I didn't want to be the guy to write yet another Clojure/SQL library - but 
 when I figured out why none of the existing ones was working for me, I had 
 no choice. :-D

 There's still plenty that can be done with the implementation, but 
 hopefully the world will look kindly on the design, and it can evolve from 
 there...

 Kris

 On Monday, 11 November 2013 11:45:21 UTC, David Della Costa wrote:

 I was about to be like, oh no, not another one! and then I read the 
 README and I thought, oh, interesting... 

 So, kudos on thinking outside the box.  I certainly agree with a lot of 
 the points you've made.  I'll definitely be playing around with this. 

 Cheers, 
 DD 

 (2013/11/11 20:10), Kris Jenkins wrote: 
  https://github.com/krisajenkins/yesql 
  
  Yesql is a simple library for blending SQL  Clojure together, 
 cleanly. 
  Here's how it works https://github.com/krisajenkins/yesql#rationale, 

  and how to use it 
 https://github.com/krisajenkins/yesql#example-usage. 
  
  Feedback welcomed, 
  Kris 
  
  -- 
  -- 
  You received this message because you are subscribed to the Google 
  Groups Clojure group. 
  To post to this group, send email to clo...@googlegroups.com 
  Note that posts from new members are moderated - please be patient 
 with 
  your first post. 
  To unsubscribe from this group, send email to 
  clojure+u...@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 unsubscribe from this group and stop receiving emails from it, 
 send 
  an email to clojure+u...@googlegroups.com. 
  For more options, visit https://groups.google.com/groups/opt_out. 



-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [ANN] Yesql 0.2.1 - Clojure SQL queries rethought.

2013-11-11 Thread Mamun
Hi Kris,

It's look fine. Is is possible to to add more query in one sql file? I 
mean- I'd like to create one sql file and store all query on that file.

BR,
Mamun



On Monday, November 11, 2013 2:38:27 PM UTC+1, Kris Jenkins wrote:

 Thanks David, that's nice of you to say. I know exactly what you mean - I 
 didn't want to be the guy to write yet another Clojure/SQL library - but 
 when I figured out why none of the existing ones was working for me, I had 
 no choice. :-D

 There's still plenty that can be done with the implementation, but 
 hopefully the world will look kindly on the design, and it can evolve from 
 there...

 Kris

 On Monday, 11 November 2013 11:45:21 UTC, David Della Costa wrote:

 I was about to be like, oh no, not another one! and then I read the 
 README and I thought, oh, interesting... 

 So, kudos on thinking outside the box.  I certainly agree with a lot of 
 the points you've made.  I'll definitely be playing around with this. 

 Cheers, 
 DD 

 (2013/11/11 20:10), Kris Jenkins wrote: 
  https://github.com/krisajenkins/yesql 
  
  Yesql is a simple library for blending SQL  Clojure together, cleanly. 
  Here's how it works https://github.com/krisajenkins/yesql#rationale, 
  and how to use it https://github.com/krisajenkins/yesql#example-usage. 

  
  Feedback welcomed, 
  Kris 
  
  -- 
  -- 
  You received this message because you are subscribed to the Google 
  Groups Clojure group. 
  To post to this group, send email to clo...@googlegroups.com 
  Note that posts from new members are moderated - please be patient with 
  your first post. 
  To unsubscribe from this group, send email to 
  clojure+u...@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 unsubscribe from this group and stop receiving emails from it, send 
  an email to clojure+u...@googlegroups.com. 
  For more options, visit https://groups.google.com/groups/opt_out. 



-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


New Leiningen template for clojure and clojurescript project

2013-11-10 Thread Mamun

Hello

New Leiningen template for Clojure and Clojurescript project. This might 
helpful to them who are coming from rails like framework and would love to 
see first before coding.  

https://github.com/Mamun/web-app

Create new project:
lein new web-app hello

Run application:
lein ring server-headless


   - Complete web application template using *Compojure*,* Enlive, Anguler 
   js* with login, logout UI.
   - Standalone/Container based deployment.  
   - Clojure workflow for starting and stopping the application.
   - Emacs-live plugin to start/stop server, Clojure/Clojurescript repl 
   switch.
   - Method level dependency injection as application context. 
   - Feature-based package modeling.
   - Testing both Clojure and Clojurescript from emacs-live.



BR,
Mamun 


-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Clojure and freelancing

2013-09-12 Thread Mamun
Pedestal is powerful framework, I don't try it. Because it is still 
changing very frequently. On the other hand I am not sure what type of 
application Pedestal is good choice. I mean game, messaging (Chat, Real 
time Chart)  or traditional CRUD based web application. But if you are 
looking something to build CRUD based web application using datomic, 
enlive, compojure. You can try this 
https://github.com/Mamun/clojure-web-app. It is not framework but template. 

BR,
Mamun

  

On Sunday, September 8, 2013 10:31:13 PM UTC+2, Mateusz Dobek wrote:

 Is Clojure good choice for one-man-webdevelopment-team?

 I switched form Ruby on Rails, and now I'm learing Clojure.  It seems to 
 be really powerfull language, but will it suits for web? 
 Wanna give it a try in Pedestal framework.


-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Building a CRUD based web application using datomic

2013-09-07 Thread Mamun
Hi 

Building a CRUD based web application using datomic. It might help some one 
who are just start using datomic to build CRUD based web application. 

URL:  https://github.com/Mamun/clojure-web-app.git

Application feature- 
Web Authentication
CRUD view for domain object
Pagination for list view
Upload data, display graph chart
log as data


Application lib-
Datomic, Compojure, Enlive, Clojure-Script, Friends, incanter

Interactive development both clojure and clojure-script using 
https://github.com/Mamun/emacs-live-clojure-workflow


BR,
Mamun

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Meta data access

2012-10-23 Thread Mamun
Hi Carlo,

Thanks. Now it is fine.

Regards,
Mamun

On Tuesday, October 23, 2012 5:24:41 AM UTC+2, Carlo wrote:

 Hey Mamun, 

 Your problem is that your ^{:test true} metadata isn't being applied 
 to your functions, as you might expect, but rather to the var that is 
 pointing to the function. You can see this in the following (#' is a 
 shorthand to get the var rather than the thing it contains). 

 user= (meta f1) 
 nil 
 user= (meta #'f1) 
 {:arglists ([]), :ns #Namespace user, :test true, :name f1, :line 1, 
 :source (clojure.core/defn ^{:test true} f1 [] (println \Call f1 
 fn\))\n, :file NO_SOURCE_PATH} 

 You can solve this in two ways: 

 1) Have `f*` contain a list of symbols, then use `resolve` [1] to get 
 the vars. Then the definition of `f*` becomes `(def f* (list 'f1 
 'f2))` 

 2) Have `f*` contain a list of vars 

 Once you have the vars then you can use `(- form meta :test)` to 
 access the value for the :test metadata. 

 Due to the way vars are implemented, calling `(form)` when `form` is a 
 var will actually call the function that `form` is pointing to, so the 
 earlier function call should continue to work. 

 I hope that helps! 

 Carlo 

 [1]: 
 http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/resolve 

 On Tue, Oct 23, 2012 at 1:30 AM, Mamun mamu...@gmail.com javascript: 
 wrote: 
  Hi All, 
  
  I've a application with following structure. Now I would like to access 
 meta 
  data of f1 and f2 within process function. 
  
  (defn ^{:test true} f1 [] 
  (println call f1 fn)) 
  
  (defn ^{:test false} f2 [] 
  (println call f2 fn)) 
  
  (def f* (list f1 f2)) 
  
  (defn process [form] 
(do 
  //Would like to access meta data of form 
  (println (str -- form 
  
  (map #(process %1) f*) 
  
  Does any one have any idea? 
  
  
  Regards, 
  Mamun 
  
  -- 
  You received this message because you are subscribed to the Google 
  Groups Clojure group. 
  To post to this group, send email to clo...@googlegroups.comjavascript: 
  Note that posts from new members are moderated - please be patient with 
 your 
  first post. 
  To unsubscribe from this group, send email to 
  clojure+u...@googlegroups.com javascript: 
  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

Meta data access

2012-10-22 Thread Mamun
Hi All,

I've a application with following structure. Now I would like to access 
meta data of f1 and f2 within process function.  

(defn ^{:test true} f1 []
(println call f1 fn))

(defn ^{:test false} f2 []
(println call f2 fn))

(def f* (list f1 f2))

(defn process [form]
  (do
*//Would like to access meta data of form* 
(println (str -- form

(map #(process %1) f*)

Does any one have any idea? 


Regards,
Mamun

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

Re: Meta data access

2012-10-22 Thread Mamun
Hi Jim

Thank for your ans. But this does not work. When I run code I got Unable 
to resolve var error. Please find in bellow:

CompilerException java.lang.RuntimeException: Unable to resolve var: form 
in this context, compiling:(NO_SOURCE_PATH:4) 

Source code-

(defn ^{:test true} f1 []
(println call f1 fn))

(defn ^{:test false} f2 []
(println call f2 fn))

(def f* (list f1 f2))

(defn process [form]
  (do
(form) ; it will call f1, f2... 
;I need to access meta data of f1, f2..
   * ;(println  (:test (meta (var form ;Error*
(println (str -- form

(map #(process %1) f*)

Regards,
Mamun



On Monday, October 22, 2012 5:45:21 PM UTC+2, Jim foo.bar wrote:

  well not quite!
 you need (- form 
var 
meta 
:test) 
 or the same thing written differently   (:test (meta (var form)))

 Hope that helps,
 Jim

 ps: basically the meta-data sit with the var not the function



 On 22/10/12 16:33, Jim foo.bar wrote:
  
 If I've understood correctly all you need is (meta form)...

 Jim

 On 22/10/12 15:30, Mamun wrote:
  
 Hi All,

 I've a application with following structure. Now I would like to access 
 meta data of f1 and f2 within process function.  

 (defn ^{:test true} f1 []
 (println call f1 fn))

 (defn ^{:test false} f2 []
 (println call f2 fn))

 (def f* (list f1 f2))

 (defn process [form]
   (do
 *//Would like to access meta data of form* 
 (println (str -- form

 (map #(process %1) f*)

 Does any one have any idea? 


 Regards,
 Mamun

 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.com javascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 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

Is there any reason to make different file extension (clj and cljs) for Clojure and ClojureScript?

2012-10-19 Thread Mamun
Hi All,

I've just started to learn Clojure and interested to see more 
ClojureScript. It is really nice stuff- data structure, function and code 
sharing. But Is there any reason to make different file extension (*.clj 
and *.cljs) for Clojure and ClojureScript?

Regards,
Mamun

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

What is the different between = and identical ?

2011-12-01 Thread Mamun
Hi,

When I run the following code, I got false for (identical? 128 128).
What is the different between = and identical?

(println (= 4 4))
true
(println (= 128 128))
true
(println (identical? 4 4))
true
(println (identical? 128 128))
false


Regards,
Mamun

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