Fork me on GitHub
#clojure
<
2018-12-18
>
andy.fingerhut00:12:34

It very well might make sense for one or more third-party REPLs to have code to try to avoid consuming some part of the input after an error occurs. The potentially tricky part is determining where in the input to start consuming input again.

jaawerth01:12:37

does pREPL run into the same problem? I don't know what pREPL solves that nREPL doesn't (I've only taken a cursory look) but I thought part of its intent was a more structure input/output to avoid such confusion

jaawerth01:12:57

nevermind, I should really just answer this myself by digging into it

seancorfield01:12:28

prepl is still going to have the same underlying issue which is that if reading code hits a parse error, the unread code is essentially unknowable, so it can only start to read again at the point where the parse error caused reading to leave off...

seancorfield01:12:56

As Andy said above, the hard part of this problem is determining what unread input to throw away before parsing should resume. You could probably come up with some heuristics but pretty much any strategy you pick is going to be "wrong" in some situations...

jaawerth02:12:13

@seancorfield gotcha, thanks. I could see a way of structuring the inputs to make it possible by allowing the inclusion of, basically, instructions/hints on this, but it would be a lot to include for that kind of thing without adding a lot of overhead

emccue03:12:42

Not really super clear from looking at the docs

emccue03:12:55

how would I implement a time based cache using core.cache

emccue03:12:20

(looks like memoize is what i want - ignore me)

emccue03:12:16

(core.memoize, not regular ol memoize

emccue03:12:34

i need a clojure.core.memoize/ttl that will clear expired on a hit

emccue03:12:44

ill just hack it

kwladyka10:12:06

Should I use clj or clojure? Today I saw: Please install rlwrap for command editing or use "clojure" instead. So there is a difference.

kwladyka10:12:51

oh I see, clj is wrapper on clojure with rlwrap

kwladyka11:12:06

hmm what is preferred way to download deps only? like lein deps? For example I want deps for clj -A:test:test-once, but I don’t want to run it. I need it to prepare docker mages.

kwladyka11:12:58

I am afraid there is no such option 😕 ?

bronsa12:12:28

clj -Sforce < /dev/null

👍 8
kwladyka12:12:48

So for example clj -Sforce -A:test:test-once?

kwladyka12:12:10

or does it download deps also for aliases?

bronsa12:12:12

no you have to specify the alias

kwladyka12:12:31

so I have to run clj -Sforce ... with all aliases

kwladyka12:12:04

~/L/M/c/s/P/f/master    clj -Sforce -A:test:test-once                                                                    3789ms  Tue Dec 18 13:05:41 2018
WARNING: var: form-validator.core/show-all is not public at line 147 /Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/form-validator/master/test/form_validator/core_test.cljs

Testing form-validator.core-test

Ran 3 tests containing 20 assertions.
0 failures, 0 errors.
hmm it actually run tests

kwladyka12:12:19

Am I doing something wrong? It looks like it doesn’t work like only download deps

kwladyka12:12:49

clj -Stree -A:test:test-once - maybe this one

kwladyka12:12:12

not sure if it download when I don’t have this deps on computer

kwladyka12:12:17

I will try soon

kwladyka13:12:17

I want to run clojure for a few deps.edn only to download dependecies. So I have foo.edn, bar.edn etc. How to run clojure with custom named deps.edn?

kwladyka13:12:19

I am thinking about -Sdeps, but it want string instead of file name

Alex Miller (Clojure team)13:12:12

There is no option for that

kwladyka13:12:30

thanks, it saves me a lot of time 🙂

Alex Miller (Clojure team)13:12:24

If you want to just download deps, you can use -Spath to just build the classpath without starting Clojure

kwladyka13:12:41

What about the best way to download deps? clojure -Spath -A:fig ? -Stree ? Something different?

Alex Miller (Clojure team)13:12:21

Either -Spath or -Stree will download without starting Clojure

danielneal14:12:47

Heya, not sure if this is a dumb question - in cljs, (keyword :a :b) gives :a/b where as in Clojure you get an error. Would it be a breaking change for Clojure for it to behave the same way?

Alex Miller (Clojure team)15:12:37

no, that doesn’t make much sense to me

Alex Miller (Clojure team)15:12:18

I don’t get how you go from :a as name a into a qualifier in :a/b - that seems quite weird to me

Alex Miller (Clojure team)15:12:46

I’d say it’s bad that cljs behaves this way :)

8
danielneal15:12:30

Ah ok, so if anything, it's more likely to be removed from cljs

danielneal15:12:14

Ah yeah, looks like the commit that did in cljs this was making keyword more restrictive; it was accepting more previously which was resulting in different hashcodes https://dev.clojure.org/jira/browse/CLJS-1779?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel#issue-tabs https://github.com/clojure/clojurescript/commit/5ac08cc0d5524e429200b1f9e68d27a5c07d5c3f

cjsauer15:12:52

What would be the "cljc" way to parse an instant from a string?

valerauko15:12:21

i'd just (Date. your-string) (not tested)

👍 4
Dustin Getz15:12:31

clojure.instant/read-instant-*

👍 12
eraserhd15:12:51

Wasn't there a way to type hint directly on a Java interop form? e.g. (^java.io.PrintWriter .println err "foo")

Alex Miller (Clojure team)15:12:39

you want the hint on the object (err)

eraserhd15:12:49

OK, that's the only way?

Alex Miller (Clojure team)15:12:21

only way to do what? back up…

eraserhd15:12:24

heh... In this case it was supposed to be *err*, and so I have to introduce a let just to type hint, and I swear I remembered there was a way to do that without the let, but I'm thinking maybe just ghost memory?

Alex Miller (Clojure team)15:12:38

(.println ^java.io.PrintWriter *err* "foo") ?

Alex Miller (Clojure team)15:12:01

maybe you misunderstood what I was suggesting above…

eraserhd15:12:41

ayup.. Thank you :)

kwladyka15:12:44

{github-kwladyka/form-validator {:git/url "" :sha ""}} - Can I set it to always pull the last commit? Without sha? Probably wouldn’t work. I need it for testing purpose in cicd.

kwladyka15:12:27

ok, thx again 🙂

Alex Miller (Clojure team)15:12:05

the intent is that a release points to a concrete commit so we don’t have support for tracking branches etc (which would also break cp caching, etc)

Alex Miller (Clojure team)15:12:50

the underlying tools.gitlibs library does support this (has broader intent), so it’s pretty easy to write a line or two of code that would tell you what the latest sha is

kwladyka15:12:18

sure, just looking the right ways to do things

kwladyka15:12:45

the simplest ways 🙂

cupello19:12:46

One silly question: How do I suppress error logging when testing a case of error? I have several "SEVERE:" in my test outputs that are really bothering me.

enforser19:12:57

are these things being printed out to the REPL or are you running your tests cases from the command line?

enforser19:12:46

There are logging libraries that let you configure which level you'd like to print at: https://github.com/ptaoussanis/timbre If you are running from the command line, then could use grep to exclude certain things from being output (might be able to do this with a REPL as well, but I've never tried it).

emccue19:12:44

Not a total answer, but a random gist for logback in particular

emccue19:12:11

clojure.tools.logging uses whatever slf4j thing you have behind the scenes i think

emccue19:12:44

so you should search for how to configure that

emccue19:12:51

(logback, log4j, whatever)

hiredman19:12:05

I really like logging to a file during test runs

hiredman19:12:52

the log file is there if you need to investigate a test failure, but you don't end up with logging in your test run

hiredman19:12:36

for example https://github.com/hiredman/raft/tree/master/test has a logback.xml in the tests directory which sets up logging for running tests

cupello20:12:26

I came from elixir and when executing lein test I would like to not print logs from some few tests (like "@tag capture_log: true" in elixir).

martinklepsch21:12:44

Usually test runners have some tooling to capture stdout.

hiredman21:12:05

just don't print logs ever when running tests, have logs go to a file

martinklepsch21:12:48

is there a function that I can give a path to a file and it will give me the corresponding namespace? e.g.

(x "project/core_test.clj") 
;; => 'project.core-test

martinklepsch21:12:50

@hiredman the issue with logging to a file is that in CI you don't usually get to look at that file after your tests failed

hiredman21:12:05

get a better ci server

martinklepsch21:12:16

while also not perfect I like stdout to be printed if a test fails

hiredman21:12:47

at my last job we had jenkins setup, jenkins ran each build in a workspace, workspaces were saved and archived, and that included the log files

hiredman21:12:04

it was great

martinklepsch21:12:54

yeah that's nice indeed — but also requires more setup 🙂

hiredman21:12:19

for other ci environments you can treat logs like another build artifact and export them to where ever you export those (s3)

dpsutton21:12:10

good devops is just amazing

futuro14:12:47

but surprisingly hard/time consuming to setup and maintain.

hiredman21:12:39

running jenkins is not rocket science

jaide22:12:15

Say you’re looking at the implementation of a popular, open-source Clojure library. One function looks pretty meaty and I think it can be broken up into several, smaller functions. Would it be acceptable to make a PR to address that or does it come off as rude or nitpicky? The choice could have been made for performance reasons but I can’t quite tell.

sgerguri23:12:44

There's only one way to find out - open a PR and be humble and clear about why you think this is a good idea. Worst that can happen is your PR gets closed.

jaide23:12:55

I see your point, but I chose to raise a question as an issue in a respectful manner to identify the problem and a proposed solution. I mentioned I’m happy to implement it and provided some thinking behind how I would. I think this has the advantage that I don’t have to invest time into it only to find out it got rejected and they don’t have to read through a PR if they’re not into the idea to begin with.

noprompt01:12:38

Big meaty functions are par for the course in my experience. Often my problem with them isn’t so much their size but their lack respect for the potential contributor. If you’re planning to make a contribution in that regard be sure that you’re improving the overall semantics of the code and not just parameterizing.

jaide01:12:52

True. I tried to focus on a problem that the meatiness causes — Which is that I can’t reuse the pieces of it I need to solve my problem and have to copy parts of it even though I’m already dependent on the library to begin with.

👍 4
jaawerth02:12:05

that's the best case for breaking a function up there is 😉

andy.fingerhut22:12:49

You might want to ask the author/maintainer of the library their thoughts on the matter, before opening a PR.

jaide22:12:52

Good idea. My instinct says to respectfully create an issue about how breaking it up would be allow other people to reuse the pieces without having to reinvent the wheel. I think that will frame it more positively towards a problem doing so will solve.

seancorfield23:12:33

Yeah, I'll often create an issue with a subject "Question: ..." and ask for their opinion on approaches, and see how the land lies before I invest in creating a PR.