Re: Is there an apply-able new?

2016-05-27 Thread Brandon Bloom
The new operation intentionally demands a statically knowable type to construct. While this is true of Java as well, it's not true of JavaScript. However, it is true of the Google Closure compiler's "type system" for advanced compilation. That said, if the library you're using isn't going to

Re: clojure.spec

2016-05-27 Thread Beau Fabry
You just need to come up with qualified names for them: user=> (require '[clojure.spec :as s]) nil user=> (s/def :base/attack (s/and integer? pos? #(<= % 1000))) :base/attack user=> (s/def :base/bonus (s/keys :req-un [:bonus/category])) :base/bonus user=> (s/valid? :base/event {:attack 100 :bonus

Re: vector of chars vs string

2016-05-27 Thread Alex Miller
On Friday, May 27, 2016 at 6:30:45 AM UTC-5, Camilo Roca wrote: > > If what I guess is right, the amount of chars that exist are finite, > Well, kind of - see Unicode. > thus Clojure treats them like a "pool of charts". > Java has a small number of primitive value types - byte, short, int,

how to reuse fspec for fdef?

2016-05-27 Thread Robert Luo
I already defined a spec for one kind of functions: (s/def ::my-handler (s/fspec :args ... :ret ...)) Then I define an instance of ::my-handler, e.g. real-handler, which I can use s/fdef to register it to registry, but can I just reuse the spec like this? (s/fdef real-handler ::my-handler)

Re: clojure.spec

2016-05-27 Thread Pedro Santos
Thanks Beau and Alex, I ended up using a different namespace and got things done! About chans: I was trying to use the spec mainly as a checker on test/dev. We have a system that communicates a lot via channels but we lose that extra check at those boundaries. Didn't think about the transducers,

Re: Avoiding nested ifs...

2016-05-27 Thread hiskennyness
On Thursday, May 26, 2016 at 10:50:24 AM UTC-4, John Szakmeister wrote: > > I'm very much a fan of bailing out early in imperative > programming as it helps to avoid a bunch of nested if conditions > that are to follow and read. This typically comes up when > checking arguments to ensure

Re: emacs Expectations Mode - can't make it work

2016-05-27 Thread Jason MacLulich
Just had to add that this emacs binding was awesome! Worked great. Thanks for posting that Sean. On Tuesday, January 26, 2016 at 4:47:16 AM UTC+11, Sean Corfield wrote: > > Yuri Steinschreiber wrote on Monday, January 25, 2016 at 1:17 AM: > > Sadly, Expectations Mode seems to be abandoned.

Deconstructing Transducers

2016-05-27 Thread Bobby Eickhoff
Precondition: I didn't really understand transducers Action: I spent some time tinkering with them Postcondition: I've written a blog post about it: Deconstructing Transducers Constructive feedback is more than

Re: clojure.spec

2016-05-27 Thread Rich Hickey
You can’t give the same qualified spec name two meanings, that’s a main point of spec. However, your actual use case you use unqualified :attack in two different contexts. - just don’t map them to the same spec. Note that ::kw is just a shorthand in the examples for fully-qualified keys, they

Re: clojure.spec

2016-05-27 Thread Alex Miller
On Friday, May 27, 2016 at 2:36:56 AM UTC-5, Pedro Pereira Santos wrote: > > Hello, > > How can I differentiate between the same keyword, but with difference > semantics? Example: > If you have different semantics, you should use different keywords (either different name or namespace). > >

Re: reader conditional not handling defmacro?

2016-05-27 Thread Alex Miller
That is one option and is in the ballpark of http://dev.clojure.org/jira/browse/CLJ-1750. On Thursday, May 26, 2016 at 11:47:09 PM UTC-5, Nathan Davis wrote: > > I can't reply to the thread on the Dev list, but here's my take. > > Unless I'm missing something, it seems to me that most these

Re: clojure.spec

2016-05-27 Thread dominic
Sorry if this is coming through a second time, I'm not having much luck with google groups. > OTOH, you may encounter user- or externally-supplied data at runtime and want to use the facilities of spec to validate/process it. Then you can use valid? or conform *explicitly* to do so.

vector of chars vs string

2016-05-27 Thread Camilo Roca
Hey guys, First of all I would like to ask some thing. In clojure the following statements results in: (identical? "foo" (str "f" "oo")) ;;=> false > (= "foo" (str "f" "oo")) ;;=> true Everything is ok with that. The next one on the other hand is what puzzles me: (identical? \f (first (str "f"

Re: Avoiding nested ifs...

2016-05-27 Thread John Szakmeister
On Thu, May 26, 2016 at 7:09 PM, Mark Engelberg wrote: > On Thu, May 26, 2016 at 1:29 PM, John Szakmeister > wrote: >> >> >> Yeah, cond is definitely useful here, but not in general. >> > > cond is useful in general, just not the cond that is

Re: clojure.spec

2016-05-27 Thread dominic
> OTOH, you may encounter user- or externally-supplied data at runtime and want to use the facilities of spec to validate/process it. Then you can use valid? or conform *explicitly* to do so. With regards to this use-case, I was wondering if there were any plans for spec to allow for

Re: reader conditional not handling defmacro?

2016-05-27 Thread Nathan Davis
Alex, On the Dev list, you mentioned you had discussed this several times with Rich and others, but were unable to reach concensus. May I ask what the hangup is (i.e., what reservations / objections were expressed) and what other options came out of those discussions? Nathan Davis On

Re: vector of chars vs string

2016-05-27 Thread Tassilo Horn
Camilo Roca writes: Hi Camilo, > Everything is ok with that. The next one on the other hand is what > puzzles me: > (identical? \f (first (str "f" "oo"))) > ;;=> true > > If what I guess is right, the amount of chars that exist are finite, > thus Clojure treats them like a

Is there an apply-able new?

2016-05-27 Thread hiskennyness
qooxdoo lets us supply oft-used widget parameters to the constructor. For example, a button can specify its label and icon at new time. And this works fine from cljs: (new qx.ui.mobile.form.Button "Go!") ;; label is the first arg But I am wrapping qooxdoo in something more concise and want

Re: Is there an apply-able new?

2016-05-27 Thread Gary Trakhman
Here's a complex example using clojure.reflect, the intent of which was to create a macro that emits type-hints for the actual constructors that are available, to resolve ambiguity when there are multiple constructors with the same number of arguments that differ in type.

Re: Is there an apply-able new?

2016-05-27 Thread Gary Trakhman
Yes, you'll have to use the reflection API to create a class dynamically. https://docs.oracle.com/javase/tutorial/reflect/member/ctorInstance.html On Fri, May 27, 2016 at 1:24 PM hiskennyness wrote: > qooxdoo lets us supply oft-used widget parameters to the constructor.

Re: Is there an apply-able new?

2016-05-27 Thread Kenneth Tilton
Thanks but... Ugh. I guess I should have mentioned this is Clojure/Javascript. Guessing clojure.reflect does not apply to JS. Sorry for the trouble. -kt On Fri, May 27, 2016 at 1:30 PM, Gary Trakhman wrote: > Here's a complex example using clojure.reflect, the intent

clojure.spec guide updated with generators

2016-05-27 Thread Alex Miller
I've added a new section to the clojure.spec guide for generators. Certainly doesn't cover everything yet but hope it helps! http://clojure.org/guides/spec#_generators -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send

Re: Avoiding nested ifs...

2016-05-27 Thread John Szakmeister
On Thu, May 26, 2016 at 5:41 PM, Erik Assum wrote: > Not being good at reading other peoples mind, I’ll give my guess as to what > Timothy was trying to suggest: > > If you define your input as a map with keys such as: > > {:type :switched ; can be :switched :dual or :something >

IoT: Clojurescript -> Jerryscript?

2016-05-27 Thread Gregg Reynolds
Hi folks, I just came across http://samsung.github.io/jerryscript/ , which Samsung apparently open-sourced last fall. Jerryscript is a bit of a misnomer, its not a language but a JS engine designed for IoT devices. Sorta like node.js only smaller, I guess. Seems to run on Zephyr on Arduino101

Re: IoT: Clojurescript -> Jerryscript?

2016-05-27 Thread Christopher Small
I imagine this should be possible, as long as JerryScript isn't missing any features needed by the js code the cljs compiles to. I'd bet most code would be fine, as long as it doesn't depend on OS features. So I would Just Try It with a simple hello world app and see how complicated you can get

Re: clojure.spec

2016-05-27 Thread Pedro Santos
Hello, How can I differentiate between the same keyword, but with difference semantics? Example: {:attack 100 :bonus {:attack {:category {:heavy 100 I have: (s/def ::attack (s/and pos? #(<= 1 1000)) (s/def ::bonus (s/keys :req-un [::attack ; <--- Is there a way to do this? -- Another