Question about tightly couple spec interactions

2018-03-29 Thread James Gatannah
Background: I'm in the process of translating a fairly low-level and messy C networking library. The original involves lots of bit-twiddling and global variables. My first pass (which has been in the "real soon now" state for months now...in hind-sight, I have some regrets about starting this at

Proper way to write EDN file, after production bug

2018-03-29 Thread Didier
Ya, I'd write a wrapping fn, like ->edn which internally binds everything to what it should be, maybe even declares some extra print defmethod if you need custom edn serialization, and returns the edn. -- You received this message because you are subscribed to the Google Groups "Clojure"

Re: Proper way to write EDN file, after production bug

2018-03-29 Thread LaurentJ
I guess we will do that and provide an helper function in an util namespace to write an EDN file safely :/ By the way does binding *print-dup* to true isn't enough to prevent any interaction of other options like : *print-length* *print-level* ? Le jeudi 29 mars 2018 21:16:54 UTC+2, Rick

Re: Writing a text adventure in Clojure

2018-03-29 Thread James Reeves
Often it's better to store the entire game state as one large, immutable data structure. Atoms are usually preferred over refs in most cases. When you want polymorphism over a map, the most common solution is to use protocols and records. On 29 March 2018 at 23:45, Will Duquette

Re: Nesting test.check's defspec tests like deftest/testing

2018-03-29 Thread Gary Fredericks
There's nothing like that in test.check proper, but you might find this useful. On Thursday, March 29, 2018 at 7:36:15 AM UTC-5, Khalid Jebbari wrote: > > Hello everyone, > > Is there a way to nest defspec tests like

Re: Writing a text adventure in Clojure

2018-03-29 Thread Timothy Baldridge
You often don't even need functions for this sort of thing. This is what is often called "data driven" programs. Simply define this as a hashmap with :description, :items, etc and then a single function that introspects this data and figures out how to describe the room. Also you might want to

Re: Writing a text adventure in Clojure

2018-03-29 Thread Will Duquette
Aha! How about this, to cut the Gordian knot: 1. The fancy room's :description isn't necessarily a simple string. It can be a vector of specs, where each spec is a text snippet or a pair containing a predicate function and a text snippet. 2. The (describe) function takes two

Writing a text adventure in Clojure

2018-03-29 Thread Will Duquette
I'm an experienced programmer, but a Clojure newbie; as a beginner project, I'm looking into how one would idiomatically write a text adventure of sorts in Clojure. I'm less interested in producing a playable game than I am in learning how to do such a thing in a proper functional style.

Re: Proper way to write EDN file, after production bug

2018-03-29 Thread Rick Moynihan
I'd suggest wrapping the code that writes via prn to the file with a dynamic binding: e.g. at a REPL: user=> (set! *print-length* 5) 5 user=> (prn (range 10)) (0 1 2 3 4 ...) nil user=> (binding [*print-length* nil] (prn (range 11))) (0 1 2 3 4 5 6 7 8 9 10) nil user=> (prn (range 10)) (0 1 2 3

Proper way to write EDN file, after production bug

2018-03-29 Thread LaurentJ
Hello, A funny bug today, our pipeline was broken because of an EDN file with ellipsis in it. It appears that the file was generated from a Clojure env with *print-length* configured. So as many have asked, do we have a better way to write EDN file other than using prn ? For the moment what

Nesting test.check's defspec tests like deftest/testing

2018-03-29 Thread Khalid Jebbari
Hello everyone, Is there a way to nest defspec tests like we can with deftest and testing ? I'm porting some tests from deftest to defspec but losing the ability to nest them make them a bit less readable. Thanks in advance -- You received this message because you are subscribed to the

Re: Best way to unit test

2018-03-29 Thread Moe Aboulkheir
bj, Is 'current-date' a top-level var in that file? If so, a good start might be a test which used with with-redefs to supply a contrived value for 'current-date', and then validated dates on either side of it. It may be less brittle to support