Guys, can this statement be justified?
--
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 unsubscr
>> wrote:
>>
>>> Try
>>>
>>> (use-fixtures :once
>>> (fn [f]
>>> (println "before")
>>> (try (f)
>>> (finally (println "after")
>>>
>>> O mércores, 25 de novembro de 2020
ry (f)
>> (finally (println "after")
>>
>> O mércores, 25 de novembro de 2020 á/s 00:17:03 UTC+1,
>> stuart.will...@gmail.com escribiu:
>>
>>> Hello,
>>>
>>> I'm experimenting with fixtures and it seems like :afte
> (finally (println "after")
>
> O mércores, 25 de novembro de 2020 á/s 00:17:03 UTC+1,
> stuart.will...@gmail.com escribiu:
>
>> Hello,
>>
>> I'm experimenting with fixtures and it seems like :after fixtures aren't
>> r
like :after fixtures aren't
> run if a test unexpectedly errors. E.g.:
>
> (use-fixtures :once {:before #(println "before")
> :after #(println "after")})
>
> (deftest a-test
> (raise (js/Error. "oops")))
>
&g
Hello,
I'm experimenting with fixtures and it seems like :after fixtures aren't
run if a test unexpectedly errors. E.g.:
(use-fixtures :once {:before #(println "before")
:after #(println "after")})
(deftest a-test
(raise (js/Error. "o
.@lvh.io> wrote:
>>>>
>>>>> Satyam: you're suggesting limiting the answers asked from run, or
>>>>> something else?
>>>>>
>>>>> On Thu, Oct 31, 2019 at 11:24 AM Satyam Ramawat <
>>>>> satyamrama...@
gt;>>
>>> On Thu, 31 Oct 2019 at 4:28 PM, Laurens Van Houtven <_...@lvh.io> wrote:
>>>
>>>> Satyam: you're suggesting limiting the answers asked from run, or
>>>> something else?
>>>>
>>>> On Thu, Oct 31, 2019 at 1
Van Houtven <_...@lvh.io> wrote:
>>
>>> Satyam: you're suggesting limiting the answers asked from run, or
>>> something else?
>>>
>>> On Thu, Oct 31, 2019 at 11:24 AM Satyam Ramawat
>>> wrote:
>>>
>>>> On a ver
t 11:24 AM Satyam Ramawat
>> wrote:
>>
>>> On a very simple way, you can restrict by using if statement by crossing
>>> checking the count/length of the list,
>>> https://clojuredocs.org/clojure.core/if
>>>
>>> On Tuesday, October 29, 2019 at 11
sting limiting the answers asked from run, or
> something else?
>
> On Thu, Oct 31, 2019 at 11:24 AM Satyam Ramawat
> wrote:
>
>> On a very simple way, you can restrict by using if statement by crossing
>> checking the count/length of the list,
>> https://clojuredoc
Satyam: you're suggesting limiting the answers asked from run, or something
else?
On Thu, Oct 31, 2019 at 11:24 AM Satyam Ramawat
wrote:
> On a very simple way, you can restrict by using if statement by crossing
> checking the count/length of the list,
> https://clojuredocs.org/c
On a very simple way, you can restrict by using if statement by crossing
checking the count/length of the list,
https://clojuredocs.org/clojure.core/if
On Tuesday, October 29, 2019 at 11:06:54 PM UTC, Laurens Van Houtven wrote:
>
> Hi,
>
> I'm trying to divide a list into
At first glance, I'd guess that the empty list is causing your problem.
You can always come up with one more path (which may not create a unique
solution, but a path to explore) that has one more empty list appended.
On Tue, Oct 29, 2019 at 6:06 PM Laurens Van Houtven <_...@lvh.io> wrote:
> Hi,
Hi,
I'm trying to divide a list into 3 lists such that (= my-list (concat a b
c)). I guess you could say I'm writing concato :-)
(l/run n
[a b c]
(l/fresh [A B] ;; uppercase are internal accumulators
(l/appendo a b A)
(l/appendo A c B)
(l/== B '(p q r s
... running this progr
No tip or payment needed for me. If at some point you desperately want to
toss some money to someone for Clojure, one possibility is to make periodic
small payments to Cognitect Labs, which also gives you access to a tool
called REBL that you may find useful at some point if you continue using
#(str/includes? value %) ["CBS" "Bar" "cat"])
>> true
>>
>> Andy
>>
>>
>> On Sat, Jun 22, 2019 at 10:32 AM Thad Guidry
>> wrote:
>>
>>> Clojure is supported as an expression language in OpenRefine. Where any
language in OpenRefine. Where any
>> cells value in OpenRefine's datagrid is just accessed by the name value.
>> Here's one of my cells value in OpenRefine...
>>
>> "001","878","245","$c","CBS Barmarick Publications,",&
ted as an expression language in OpenRefine. Where any
> cells value in OpenRefine's datagrid is just accessed by the name value.
> Here's one of my cells value in OpenRefine...
>
> "001","878","245","$c","CBS Barmarick Publications
Clojure is supported as an expression language in OpenRefine. Where any
cells value in OpenRefine's datagrid is just accessed by the name value.
Here's one of my cells value in OpenRefine...
"001","878","245","$c","CBS Barmarick Public
Ah right, I see now.
Ya, so it seems macros are fully expanded first, and then constant are
inlined, and then code is evaled.
So there's really no way to specify a global to be used within a macro
itself, unless you resolve it explicitly within your macro, using resolve
or eval, or if yo
ple, I get:
>>
>> ClassCastException clojure.lang.Symbol cannot be cast to java.lang.Number
>> clojure.lang.Numbers.add
>>
>> When I macroexpand-1 my example, I also get the same ClassCastException.
>>
>> But if we follow your step by step, you make it soun
java.lang.Number
> clojure.lang.Numbers.add
>
> When I macroexpand-1 my example, I also get the same ClassCastException.
>
> But if we follow your step by step, you make it sound like it would work
> and return 110.
>
> So at which step would this exception be thrown?
be cast to java.lang.Number
clojure.lang.Numbers.add
When I macroexpand-1 my example, I also get the same ClassCastException.
But if we follow your step by step, you make it sound like it would work
and return 110.
So at which step would this exception be thrown? And why?
On Thursday, 15 Ma
The compiler seems to currently use the *:const* hint, to know that it
should return the analyzed expression value for the var (as if it was
quoted) instead of the *VarExpr* (which would mean a deref at run-time)
(see here
<https://github.com/clojure/clojure/blob/master/src/jvm/clojure/l
>
> Macroexpansion is given the raw forms that are read, and I think
> that's a good thing. Inside a macro you can always call
> macroexpand yourself if you want to (or resolve values another
> way) but there's no way to "undo" automatic macroexpansio
Hey Stephen,
On Fri, Sep 21 2018, Stephen Feyrer wrote:
user=> (def some-numbers ‘(2 4 6 8)) #This is my value to test
later.
#’user/some-numbers
At this point we have some-numbers = '(2 4 6 8)
user=> (def evens? (partial (when (apply = (map even?
some-numbers)
#’user/evens?
Let's w
hy Clojure/Rich did not provide
continuations.
On Monday, December 11, 2017 at 5:56:29 PM UTC-6, Stephen Feyrer wrote:
>
> Hi there,
>
> I have been trying to shake this thought for a while now. Essentially, my
> thought was if you can return a function why not decision component of an
Should have been:(evens? nil)
On Thu, Sep 20, 2018 at 1:47 PM Alan Thompson wrote:
> `println` always returns `nil`. So it prints "one", returns `nil`, and
> you try to execute the form:
>
> (nil) => NullPointerException
>
>
> user=> (evens? (println “one”))
> one
> NullPointerException
be worth a watch.
>>>
>>> On Mon, Dec 11, 2017 at 4:56 PM, Stephen Feyrer <
>>> stephen.fey...@gmail.com> wrote:
>>>
>>>> Hi there,
>>>>
>>>> I have been trying to shake this thought for a while now. Essentially
>>>
>>>> On Mon, Dec 11, 2017 at 4:56 PM, Stephen Feyrer
>>>> wrote:
>>>> Hi there,
>>>>
>>>> I have been trying to shake this thought for a while now. Essentially, my
>>>> thought was if you can r
>>> wrote:
>>> I talked a bit about this in my video on Boolean Blindness:
>>> https://www.youtube.com/watch?v=K1LaaJMscCc
>>>
>>> Might be worth a watch.
>>>
>>>> On Mon, Dec 11, 2017 at 4:56 PM, Stephen Feyrer
>>>
> wrote:
>
>> I talked a bit about this in my video on Boolean Blindness:
>> https://www.youtube.com/watch?v=K1LaaJMscCc
>>
>> Might be worth a watch.
>>
>> On Mon, Dec 11, 2017 at 4:56 PM, Stephen Feyrer > > wrote:
>>
>>> Hi there,
&
would work?
Macroexpansion is given the raw forms that are read, and I think
that's a good thing. Inside a macro you can always call
macroexpand yourself if you want to (or resolve values another
way) but there's no way to "undo" automatic macroexpansion.
As one particula
if that < is the prefix that's should work or that programs crappy.
--
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 - plea
I was hoping that ^:const would be able to inline any symbol value and that
it would do so before macroexpanssion so that:
(def ^:const bar {:a 100})
(defmacro foo
[x]
(:a x))
(foo bar)
Would return:
100
The same way that:
(foo {:a 100})
does.
Then I read that ^:const only inlines pri
I’m a pretty heavy user of spec including a lot of coercion. The way I’ve
always done coercion is to enumerate all accepted shapes first and do coercion
last. For your example this would be:
(s/def ::foo (s/and (s/or :string string?
:kw keyword?)
I've been using the macro below to make "types" in the context of
clara-rules, where "type" has a specific semantic. If you're going to do
something like this, you definitely should have a very well-defined notion
of what "type" means.
(defmacro def-de
Nice!
On Monday, February 26, 2018 at 8:47:38 AM UTC-6, Wilker wrote:
>
> I've written a library that tries to solve this, instead of making
> conforms that do coercion, it uses the spec and a separated registry to
> conform the value (similar to what spec does to find the generators for a
> gi
ely do this already. When you have s/keys maps which are
>> sets of attributes, you can simply combine sets (base and extensions) using
>> s/merge. Or when needing more polymorphism, s/multi-spec.
>>
>
> I guess I'm talking about Types as in primitive types included. S
phism, s/multi-spec.
>
I guess I'm talking about Types as in primitive types included. So if I
create a String type, I can describe what is the set of values for the type
using a spec. Similarly, I now know that the Type and the Spec used to
describe its possible set of values are equivalent
onable “ask” for the guide to be updated to
> include such a caution).
>
>
>
> My recommendation is to have a strictly non-coercive spec for the target
> data “type” / shape you want, and to have a second spec that combines the
> coercion you want with that spec. That way you
On Wednesday, February 21, 2018 at 7:34:00 PM UTC-6, Didier wrote:
>
> I would actually love it if Spec was extended to have the concept of types.
>
Map specs are about attribute aggregation, not about types.
https://clojure.org/about/spec#_map_specs_should_be_of_keysets_only
&g
I would actually love it if Spec was extended to have the concept of types.
Something where every spec could be tied to a Type, and types could be
constructed to have Hierarchies.
Not sure what the syntax would be like, but say:
(s/def :String ::name string?)
(s/def :String ::address (s/and
).
My recommendation is to have a strictly non-coercive spec for the target data
“type” / shape you want, and to have a second spec that combines the coercion
you want with that spec. That way you have a way to tell if your uncoerced data
conforms to the spec, as well as a way to do coercion in s
ys).
>
I am afraid that ship has sailed. Looking around I see lots of cases where
people do use conformers for coercion. At a first glance it seems very
natural, and warnings not to do it are not easily found.
> This is a common need though and I would be happier if spec did more to
>
see the problems driving this, and I agree there is a gap to be filled
> here though.
>
This is good.
There is also https://dev.clojure.org/jira/browse/CLJ-2251 by me, which
would be my top1 wish for spec: one open `s/walk*` (replacing `s/conform*`
and `s/unform*`) for specs and sup
Calling s/valid? will tell me if the data is valid *if it has been conformed*.
But what if it hasn't? Can I use the data? Is it "valid" according to the spec
I wrote?
If your spec includes coercions, you have inherently made the “is valid?”
question include the coercion. Y
On Tuesday, February 20, 2018 at 11:24:19 AM UTC-6, Erik Assum wrote:
>
> Out of curiosity, are you at liberty to discuss how Cognitect solves the
> problem of validating/coercing values at the edges of the application when
> you (Cognitect) are doing consulting?
I'm not involved with those t
Out of curiosity, are you at liberty to discuss how Cognitect solves the
problem of validating/coercing values at the edges of the application when you
(Cognitect) are doing consulting?
Erik.
--
i farta
> 20. feb. 2018 kl. 18:05 skrev Alex Miller :
>
> I do see the problems driving this, and
On Tuesday, February 20, 2018 at 10:28:12 AM UTC-6, Erik Assum wrote:
>
> FWIW, I’ve been using https://github.com/metosin/spec-tools
> on a couple of projects lately, which helps nicely with
> conformance and coercion. The main devs are very helpful on #ring-swagger
> on the Clojurians slack.
>
).
>
> This is a common need though and I would be happier if spec did more to help
> you solve it in a way that minimized repetition and maximized the use of
> existing specs. I'm still thinking through what that would mean exactly. It's
> challenging right now
This is exactly why we recommend that you not use conformers for coercion.
Conformers were added primarily as a tool for building custom composite
spec types (for example, we used it to build keys* from keys).
This is a common need though and I would be happier if spec did more to
help you
mers are keyword and set.
And it works really well, except for one problem: there is no way to know
if data has been conformed or not.
Calling s/valid? will tell me if the data is valid *if it has been
conformed*. But what if it hasn't? Can I use the data? Is it "valid"
accord
2018-02-01 3:24 GMT+01:00 scott stackelhouse :
> CRIU seems like it could actually help in this case. In particular,
> paired with Docker, I can just restart from a known good checkpoint with
> editor loaded, repl up and connected, etc. That would be very nice.
>
Yep, it nice. Although, with CR
I was just reading about Docker+CRIU.
For me, the slow startup isn't much of a bother for normal operations of my
apps. They are generally long running services. But development is where I am
bothered by it the most. It can be painful to restart a repl and it's very
disruptive to my abilit
With the help of criu [1], I can get clojure's startup time on jdk 1.8 down
to around 300 - 350 ms [2]
This could be considered cheating, because it only works on linux with
`CONFIG_CHECKPOINT_RESTORE=y`, but it also demonstrates, what can be
achieved with kernel support.
[1] https://criu.org/
[2
In Lumo case there is heavy optimisation of startup time in not loading
CLJS from JS sources at all. They use V8 Startup Snapshots.
See https://anmonteiro.com/2016/11/the-fastest-clojure-repl-in-the-world/
for more details.
Dne sobota 15. července 2017 0:20:28 UTC+2 Didier napsal(a):
>
> This l
p a project with a lot of non-AOT'ed
>>> code - the 10s of seconds of read/compile/init times dwarf this stuff. Rich
>>> and I working on an idea to help with this.
>>>
>>> On Thursday, January 25, 2018 at 11:47:32 PM UTC-6, Nathan Fisher wrote:
>>
sday, January 25, 2018 at 11:47:32 PM UTC-6, Nathan Fisher wrote:
>>>
>>> It's not a huge contributor but Class loading isn't free and Clojure
>>> could optimise it in a couple of places. I think with a couple of months
>>> effort in optimisation you
On Friday, January 26, 2018 at 12:39:06 PM UTC-6, Justin Smith wrote:
>
> a nitpick on point 1 - I would assume you can't expect hotspot to improve
> anything in the timescale of a program startup
>
hard to say there are a lot of lock optimizations. I'm not well-versed
enough in that stuff
gt; could optimise it in a couple of places. I think with a couple of months
>> effort in optimisation you might be able to get it down to 500ms for a
>> simple "hello world". I'm doubtful you can get it much lower than that. TBH
>> I'm not sure if the engineeri
ouple of months effort
> in optimisation you might be able to get it down to 500ms for a simple
> "hello world". I'm doubtful you can get it much lower than that. TBH I'm
> not sure if the engineering effort would necessarily be worth it for many
> users.
>
>
er than that. TBH I'm
not sure if the engineering effort would necessarily be worth it for many
users.
I wanted to test dynamic loading and docker before I shared the article
more broadly but here's the results from implementing prefetching in
Clojure;
https://junctionbox.ca/2018/01/04/clo
ms in play here are completely different. So I re-state what I
said before: it's apples-to-oranges.
But I'd love to see more benchmarks in this thread, so far we only have
opinions.
On Thu, Jan 25, 2018 at 9:37 PM, Timothy Baldridge
wrote:
> >> If Var reification is part of the s
>> If Var reification is part of the slowness of Clojure startup over Java's
It's really not. If you completely removed vars from Clojure on the JVM,
Clojure wouldn't be faster by any measurable amount. If someone has
benchmarks that say that Vars themselves are the cause of
>
> Really, any comparisons between JS and JVM startup times are not useful at
> all.
I'd say its useful to me, if anything because I've learned quite a few
things already from this comparison, and I hope to learn more.
If Var reification is part of the slowness of C
Really, any comparisons between JS and JVM startup times are not useful at
all. For a long list of reasons, not limited to:
* CLJS doesn't have Vars, CLJ does
* JS VMs are highly tuned for excellent startup times
* JVM Bytecode is a binary format expressing classes, JS files are text
files express
The JVM is concurrent whereas Javascript VMs are singled-threaded. Var
initialisation in Clojure uses concurrency primitives to ensure that
namespaces are always consistent for all threads, whereas Clojurescript
simply assigns to variables. Our profiling of Clojure on the JVM indicates
that a lot o
cljs vars are not reified.
On Thu, 25 Jan 2018, at 18:24, Didier wrote:
> Based on the profiling performed here
> http://clojure-goes-fast.com/blog/clojures-slow-start/ on 1.9,
>
> It looks like clojure/core__init.load is the slowest bit with load and
> requiring spending the most time on, as w
Based on the profiling performed here
http://clojure-goes-fast.com/blog/clojures-slow-start/ on 1.9,
It looks like clojure/core__init.load is the slowest bit with load and
requiring spending the most time on, as well as loadClass, followed by
clojure/lang/Var.invoke.
Wouldn't ClojureScript als
advantage of). When I have profiled it, reading and compiling usually end
up being about the same order of magnitude. Var initialization varies a lot
(you could be doing anything in there), but certainly having work to do for
every var has a cost that adds up, particularly if you load 100s of
n
t; So in my understanding it mostly boils down to the ability to define
> objects directly, so they can just be loaded in memory, versus having to
> load and execute code to create the objects.
>
> On 24 Jan 2018, at 09:09, Didier wrote:
>
> So if that is true, then the slow st
jects
directly, so they can just be loaded in memory, versus having to load and
execute code to create the objects.
> On 24 Jan 2018, at 09:09, Didier wrote:
>
> So if that is true, then the slow startup times are to blame on Java. I
> understand that Clojure does a lot of extra
So if that is true, then the slow startup times are to blame on Java. I
understand that Clojure does a lot of extra stuff at startup that a plain
Java main method would not, but those extra things Clojure does are slow,
because of the way the JVM handles them, where as they are quite fast on V8
PM, Stephen Feyrer
> wrote:
>
>> Hi there,
>>
>> I have been trying to shake this thought for a while now. Essentially,
>> my thought was if you can return a function why not decision component of
>> an IF, WHEN or SOME statement? That would give you a
I talked a bit about this in my video on Boolean Blindness:
https://www.youtube.com/watch?v=K1LaaJMscCc
Might be worth a watch.
On Mon, Dec 11, 2017 at 4:56 PM, Stephen Feyrer
wrote:
> Hi there,
>
> I have been trying to shake this thought for a while now. Essentially, my
> though
Hi there,
I have been trying to shake this thought for a while now. Essentially, my
thought was if you can return a function why not decision component of an
IF, WHEN or SOME statement? That would give you a re-usable named choice.
Then you could write:
(celebration: do-something do-something
My mental model explains most of this away due to the different load
patterns of java vs v8. In JVM clojure, functions are essentially 1:1 with
classes, so in a functional language and standard lib, that's a lot of
classes. Java will eagerly classload your entire app and deps before doing
any wor
This link:
https://dev.clojure.org/display/design/Improving+Clojure+Start+Time says
that the Java startup time is ~94 ms, while Clojure boot time is ~640 ms.
That's a ~680% increase.
On my machine the java start time is: ~1042 ms, and the Clojure start time
is around ~3108 ms. A ~298% increase
var.
The ‘def’ form is parsed in DefExpr$Parser.parse() and it calls lookupVar(sym,
true) – which interns the symbol if it is new (i.e., not yet seen). See various
parts of:
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java
Sean Corfield -- (970) FOR-SEA
I admit, this is very surprising. It looks like evaluation happens in two pass,
like first it finds all defs and declares them, interning the symbol and
creating an unbound var. And on a second pass it evaluates the full form.
Can someone more informed confirm or explain in more details what's r
It creates an "undefined" var if the def gets compiled but doesn't get run.
This isn't the same as an "undefined behavior" as is documented for
languages that have formal specifications (clojure of course has none). I
did qualify that def / defn inside other forms
Thanks Justin,
Sadly in my case those mutable container will not work because I was making
a monkey-patch to a bug in a macro from other package.
Despite what I was doing, I think "a bad design" in clojure spec is too
weak to fit this situation. If someone tells me "it is
Clojure's compiler (there's no interpreter) creates vars for every def
inside a form it compiles. Before the def actually runs it's unbound (as if
you had used declare).
Generally def and defn that are not top level forms are signs of a bad
design. If you need runtime rebindi
Hi,
Recently encountered a weird issue, A def in if clause declared a var but
left it unbound.
I encountered this issue when I was trying to implement something like
"define a symbol if it is not defined yet". Naively I tried:
(if (nil? (resolve 'foo))
(def foo 42))
; Cann
On Tuesday, 31 January 2017 10:25:31 UTC+11, Leon Grapenthin wrote:
>
> Hi Sayth, welcome to Clojure.
>
> Read like this:
>
> (nil? nil)
> ;-> true
> Is nil nil? True.
>
> (true? nil)
> ;-> false
> Is nil true? False.
>
> Kind regards,
> Leon.
>
>
Thanks Leon. Yeah it does make sense it just
Hi Sayth, welcome to Clojure.
Read like this:
(nil? nil)
;-> true
Is nil nil? True.
(true? nil)
;-> false
Is nil true? False.
Kind regards,
Leon.
On Monday, January 30, 2017 at 8:34:09 AM UTC+1, Sayth Renshaw wrote:
>
> Hi
>
> If nil is true
>
> clojure-noob
On Monday, January 30, 2017 at 1:34:09 AM UTC-6, Sayth Renshaw wrote:
>
> Hi
>
> If nil is true
>
> clojure-noob.core> (nil? nil)
> true
>
Similarly,
user=> (false? false)
true
--
You received this message because you are subscribed to the Google
Groups &q
Sayth, check out these examples and see if they clarify anything for you.
user=> nil
nil
user=> (if nil "nil is truthy" "nil is falsey")
"nil is falsey"
user=> (nil? nil)
true
user=> (if (nil? nil) "(nil? nil)=true is truthy" "(nil
On Monday, 30 January 2017 19:02:08 UTC+11, Sayth Renshaw wrote:
>
>
>
> On Monday, 30 January 2017 18:53:44 UTC+11, Alan Forrester wrote:
>>
>>
>> > Hi
>> >
>> > If nil is true
>> >
>> > clojure-noob.core> (nil? nil)
On Monday, 30 January 2017 18:53:44 UTC+11, Alan Forrester wrote:
>
>
> > Hi
> >
> > If nil is true
> >
> > clojure-noob.core> (nil? nil)
> > true
> >
> > Then why doesn't nil return from this statement as the first true valu
On 30 Jan 2017, at 07:34, Sayth Renshaw wrote:
> Hi
>
> If nil is true
>
> clojure-noob.core> (nil? nil)
> true
>
> Then why doesn't nil return from this statement as the first true value?
This expression is a function invocation. The function is the first it
Hi
If nil is true
clojure-noob.core> (nil? nil)
true
Then why doesn't nil return from this statement as the first true value?
clojure-noob.core> (or false nil true)
true
Sausages does as expected.
clojure-noob.core> (or false "sausages" true)
"sausages"
Th
Here is the if-let*:
(defmacro if-let*
([bindings then]
`(if-let* ~bindings ~then nil))
([bindings then else]
(if (seq bindings)
`(if-let [~(first bindings) ~(second bindings)]
(if-let* ~(drop 2 bindings) ~then ~else)
~(if-not (second bindings) else))
then)))
And when-let*:
(defmacro when-let
> On Jul 1, 2016, at 10:34 AM, Timothy Baldridge wrote:
>
> You can write a protocol, then extend it: ...
Ah! I completely blanked on protocol dispatch being resolved at compile time if
possible. Thanks!
Does this only work if the type hint is exactly the extended type, or
You can write a protocol, then extend it:
(defprotocol IBufferLength
(buffer-length [this]))
(extend-protocol IBufferLength
(Class/forName "[B")
(buffer-length [this] ...)
ByteBuffer
(buffer-length [this] ...))
On Fri, Jul 1, 2016 at 9:15 AM, Erik Assum wrote:
> A multimethod which
A multimethod which dispatches on type, or maybe extend the counted(?) protocol
to these two types?
Erik.
--
i farta
> Den 1. jul. 2016 kl. 17.12 skrev lvh <_...@lvh.io>:
>
> Hi,
>
>
> I have some code that wants to know the appropriate length of a byte buffer.
> These can be byte arrays (
Hi,
I have some code that wants to know the appropriate length of a byte buffer.
These can be byte arrays (as in [B) or java.nio.ByteBuffers. For the former, I
can call (alength ^bytes buf), for the latter I call (.remaining ^ByteBuffer
buf). Is there a way to just write a fn or macro that pic
Perhaps it shouldn't even be available in Clojurescript.
http://i.imgur.com/A0TyNGN.png
On Thursday, May 19, 2016 at 3:14:27 PM UTC-5, Alex Miller wrote:
>
> I think the biggest question mark is what it would return... could be:
>
> - System/currentTimeMillis (long)
> - System/nanoTime (long)
>
1 - 100 of 695 matches
Mail list logo