Clojure which would not work correctly if variables were allocated on the stack.

2023-03-12 Thread Sumeet
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

Re: cljs.test :after fixture not called if test errors

2020-11-27 Thread Stuart Campbell
>> wrote: >> >>> Try >>> >>> (use-fixtures :once >>> (fn [f] >>> (println "before") >>> (try (f) >>> (finally (println "after") >>> >>> O mércores, 25 de novembro de 2020

Re: cljs.test :after fixture not called if test errors

2020-11-25 Thread David Nolen
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

Re: cljs.test :after fixture not called if test errors

2020-11-24 Thread Stuart Campbell
> (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

Re: cljs.test :after fixture not called if test errors

2020-11-24 Thread Estevo U. C. Castro
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

cljs.test :after fixture not called if test errors

2020-11-24 Thread Stuart Campbell
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

Re: Why does this core.logic program never terminate if you ask for too many results?

2019-11-01 Thread Satyam Ramawat
.@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...@

Re: Why does this core.logic program never terminate if you ask for too many results?

2019-11-01 Thread Laurens Van Houtven
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

Re: Why does this core.logic program never terminate if you ask for too many results?

2019-10-31 Thread Satyam Ramawat
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

Re: Why does this core.logic program never terminate if you ask for too many results?

2019-10-31 Thread Laurens Van Houtven
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

Re: Why does this core.logic program never terminate if you ask for too many results?

2019-10-31 Thread Satyam Ramawat
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

Re: Why does this core.logic program never terminate if you ask for too many results?

2019-10-31 Thread Laurens Van Houtven
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

Re: Why does this core.logic program never terminate if you ask for too many results?

2019-10-31 Thread Satyam Ramawat
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

Re: Why does this core.logic program never terminate if you ask for too many results?

2019-10-31 Thread Marc Limotte
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,

Why does this core.logic program never terminate if you ask for too many results?

2019-10-29 Thread Laurens Van Houtven
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

Re: Shorter form to check if some words are contained in a sentence?

2019-06-22 Thread Andy Fingerhut
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

Re: Shorter form to check if some words are contained in a sentence?

2019-06-22 Thread Thad Guidry
#(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

Re: Shorter form to check if some words are contained in a sentence?

2019-06-22 Thread Andy Fingerhut
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,",&

Re: Shorter form to check if some words are contained in a sentence?

2019-06-22 Thread Andy Fingerhut
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

Shorter form to check if some words are contained in a sentence?

2019-06-22 Thread Thad Guidry
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

Re: What if ^:const could inline everything before macroexpanssion?

2018-11-07 Thread Didier
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

Re: What if ^:const could inline everything before macroexpanssion?

2018-11-07 Thread juan.facorro
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

Re: What if ^:const could inline everything before macroexpanssion?

2018-11-07 Thread juan.facorro
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?

Re: What if ^:const could inline everything before macroexpanssion?

2018-11-07 Thread Didier
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

Re: What if ^:const could inline everything before macroexpanssion?

2018-11-04 Thread juan.facorro
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

Re: What if ^:const could inline everything before macroexpanssion?

2018-11-04 Thread Didier
> > 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

Re: IF, WHEN or SOME

2018-09-20 Thread Carlo Zancanaro
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

Re: IF, WHEN or SOME

2018-09-20 Thread Paul Rutledge
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

Re: IF, WHEN or SOME

2018-09-20 Thread Alan Thompson
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

Re: IF, WHEN or SOME

2018-09-20 Thread Alan Thompson
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

Re: IF, WHEN or SOME

2018-09-20 Thread Orestis Markou
>>> >>>> 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

Re: IF, WHEN or SOME

2018-09-20 Thread Orestis Markou
>>> 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 >>>

IF, WHEN or SOME

2018-09-20 Thread 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, &

Re: What if ^:const could inline everything before macroexpanssion?

2018-03-15 Thread Carlo Zancanaro
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

Re: What if ^:const could inline everything before macroexpanssion?

2018-03-15 Thread overtoxic9
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

What if ^:const could inline everything before macroexpanssion?

2018-03-15 Thread Didier
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

Re: s/valid? does not tell me if the data is valid as supplied

2018-02-26 Thread Simon Belak
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?)

Re: s/valid? does not tell me if the data is valid as supplied

2018-02-26 Thread Dave Dixon
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

Re: s/valid? does not tell me if the data is valid as supplied

2018-02-26 Thread Alex Miller
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

Re: s/valid? does not tell me if the data is valid as supplied

2018-02-26 Thread Wilker
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

Re: s/valid? does not tell me if the data is valid as supplied

2018-02-22 Thread Didier
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

Re: s/valid? does not tell me if the data is valid as supplied

2018-02-22 Thread Jan Rychter
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

Re: s/valid? does not tell me if the data is valid as supplied

2018-02-21 Thread Alex Miller
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

Re: s/valid? does not tell me if the data is valid as supplied

2018-02-21 Thread Didier
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

RE: s/valid? does not tell me if the data is valid as supplied

2018-02-21 Thread Sean Corfield
). 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

Re: s/valid? does not tell me if the data is valid as supplied

2018-02-21 Thread Jan Rychter
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 >

Re: s/valid? does not tell me if the data is valid as supplied

2018-02-20 Thread Tommi Reiman
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

RE: s/valid? does not tell me if the data is valid as supplied

2018-02-20 Thread Sean Corfield
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

Re: s/valid? does not tell me if the data is valid as supplied

2018-02-20 Thread Alex Miller
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

Re: s/valid? does not tell me if the data is valid as supplied

2018-02-20 Thread Erik Assum
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

Re: s/valid? does not tell me if the data is valid as supplied

2018-02-20 Thread Alex Miller
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. >

Re: s/valid? does not tell me if the data is valid as supplied

2018-02-20 Thread Erik Assum
). > > 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

Re: s/valid? does not tell me if the data is valid as supplied

2018-02-20 Thread Alex Miller
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

s/valid? does not tell me if the data is valid as supplied

2018-02-20 Thread Jan Rychter
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

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-02-01 Thread Herwig Hochleitner
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

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-31 Thread scott stackelhouse
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

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-28 Thread Herwig Hochleitner
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

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-28 Thread Aleš Roubíček
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

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-26 Thread Nathan Fisher
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: >>

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-26 Thread Nathan Fisher
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

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-26 Thread Alex Miller
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

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-26 Thread Justin Smith
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

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-26 Thread Alex Miller
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. > >

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-25 Thread Nathan Fisher
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

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-25 Thread Timothy Baldridge
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

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-25 Thread Timothy Baldridge
>> 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

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-25 Thread Didier
> > 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

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-25 Thread Timothy Baldridge
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

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-25 Thread Stephen Nelson
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

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-25 Thread Mikhail Gusarov
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

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-25 Thread Didier
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

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-24 Thread Alex Miller
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

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-24 Thread Gary Trakhman
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

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-24 Thread Gary Verhaegen
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

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-24 Thread Didier
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

Re: IF, WHEN or SOME

2017-12-11 Thread Stephen Feyrer
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

Re: IF, WHEN or SOME

2017-12-11 Thread Timothy Baldridge
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

IF, WHEN or SOME

2017-12-11 Thread Stephen Feyrer
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

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2017-07-14 Thread Gary Trakhman
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

If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2017-07-14 Thread Didier
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

Re: def partially done when used in if

2017-06-30 Thread Sean Corfield
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

Re: def partially done when used in if

2017-06-30 Thread Didier
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

Re: def partially done when used in if

2017-06-29 Thread Justin Smith
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

Re: def partially done when used in if

2017-06-29 Thread Kaiming Yang
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

Re: def partially done when used in if

2017-06-29 Thread Justin Smith
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

def partially done when used in if

2017-06-29 Thread Kaiming Yang
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

Re: if nil is true

2017-01-31 Thread Sayth Renshaw
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

Re: if nil is true

2017-01-30 Thread Leon Grapenthin
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

Re: if nil is true

2017-01-30 Thread Mars0i
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

Re: if nil is true

2017-01-30 Thread Andy Fingerhut
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

Re: if nil is true

2017-01-30 Thread Sayth Renshaw
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)

Re: if nil is true

2017-01-30 Thread Sayth Renshaw
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

Re: if nil is true

2017-01-29 Thread 'Alan Forrester' via Clojure
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

if nil is true

2017-01-29 Thread Sayth Renshaw
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

Re: if-let/when-let

2016-07-26 Thread Ertuğrul Çetin
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

Re: Picking a code path if a type is known at compile time (e.g. through hint)

2016-07-01 Thread lvh
> 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

Re: Picking a code path if a type is known at compile time (e.g. through hint)

2016-07-01 Thread Timothy Baldridge
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

Re: Picking a code path if a type is known at compile time (e.g. through hint)

2016-07-01 Thread Erik Assum
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 (

Picking a code path if a type is known at compile time (e.g. through hint)

2016-07-01 Thread lvh
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

Re: Why is there no core/system-time in Clojure if it is in ClojureScript?

2016-05-19 Thread Daniel
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   2   3   4   5   6   7   >