RE: dynamically defining specs

2019-02-19 Thread Sean Corfield
Is there a way to programmatically create a spec from data?

There will be in Spec2 (which is a work-in-progress – see Alex’s Inside Clojure 
Journal posts for the state of that work).

Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood


From: clojure@googlegroups.com  on behalf of Sonny To 

Sent: Tuesday, February 19, 2019 4:18:20 AM
To: Clojure
Subject: dynamically defining specs

(let [n :foo/bar
f int?]
(s/def n f)
)

(s/get-spec :foo/bar)

why does this return nil?

it seems I can only define a spec like this

(s/def :foo/bar int?)

Is there a way to programmatically create a spec from data?

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

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

2019-02-19 Thread Sonny To
s/def is a macro so it doesn't evaluate the parameter n.
had to use s/def-impl instead like this


  (let [n :foo/bar3
f int?]
(s/def-impl n n f)
)

On Tuesday, February 19, 2019 at 1:18:20 PM UTC+1, Sonny To wrote:
>
> (let [n :foo/bar
> f int?]
> (s/def n f)
> )
>
> (s/get-spec :foo/bar)
>
> why does this return nil?
>
> it seems I can only define a spec like this
>
> (s/def :foo/bar int?)
>
> Is there a way to programmatically create a spec from data?
>

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


dynamically defining specs

2019-02-19 Thread Sonny To
(let [n :foo/bar
f int?]
(s/def n f)
)

(s/get-spec :foo/bar)

why does this return nil?

it seems I can only define a spec like this

(s/def :foo/bar int?)

Is there a way to programmatically create a spec from data?

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