<FromGitter>
<anicholson> @dscottboggs_gitlab are those `receive?` methods non-blocking, then?
<FromGitter>
<dscottboggs_gitlab> so in this way crystal's case..when functions both like go's switch-case and select-case, the difference being in what goes into the when conditions
<FromGitter>
<dscottboggs_gitlab> yes they return nil if nothing is on the channel yet, a value if it is
<FromGitter>
<dscottboggs_gitlab> I should double check that and maybe add some documentation to the Channel class
<FromGitter>
<anicholson> is this some === sorcery like Ruby's `case` statement?
<FromGitter>
<dscottboggs_gitlab> my example was wholly incomplete now that I look back on it, more like a rough sketch
<FromGitter>
<fenicks> @dscottboggs_gitlab I think it could be done but I don't know about the right way to do that. ⏎ `select when` or `case when`. Is a core ticker exist ? I probably need to build my own Ticker.
<FromGitter>
<dscottboggs_gitlab> Yes, I think you'll need to build a ticker which emits a truthy value
<FromGitter>
<dscottboggs_gitlab> `when` blocks get executed when they receive a truthy value, nil is falsy
<FromGitter>
<fenicks> Ok, thanks guys
<FromGitter>
<dscottboggs_gitlab> could you let me know if you get that working?
<FromGitter>
<dscottboggs_gitlab> It would make a good example for the Channel documentation
<FromGitter>
<fenicks> Ok
<FromGitter>
<drujensen> @dscottboggs_gitlab Yes, this would make an excellent example. Syntax looks much cleaner than Go. I love Crystal!
<FromGitter>
<drujensen> could you use one channel with different responses like `:ticker` and `:done`?
<FromGitter>
<drujensen> or each span needs its own channel?
<FromGitter>
<dscottboggs_gitlab> I think it makes more sense to have separate channels for concepts like done and ticker but it could certainly be useful to perform actions based on data passed through channels; that's mainly what they're there for.
<FromGitter>
<dscottboggs_gitlab> I love fibers/channels/goroutines as a concurrency pattern
<FromGitter>
<dscottboggs_gitlab> > or each spawn needs its own channel? ⏎ ⏎ I think that is the best idea yes.
<FromGitter>
<m-o-e> hmm, is there a way to get a property by name? as in: instance.get_property("foobar")
<FromGitter>
<proyb6> How do I receive raw HTTP contents or request from user in byte, I want to see if I can bypass the HTTP context.request and middleware.
akaiiro has quit [Remote host closed the connection]
<FromGitter>
<Blacksmoke16> here's a question of preference
<FromGitter>
<Blacksmoke16> to justify my thinking
<FromGitter>
<proyb6> Noted, I thought about Actix-raw could raw requests to bypass overhead, will be awesome how efficient we can do in Crystal as well
<FromGitter>
<jeff-hykin> How unrealistic is it to compile crystal to c? (or wasm)
<FromGitter>
<dscottboggs_gitlab> @fenicks I wasn't aware of the select top-level method. where did you find that?
<FromGitter>
<dscottboggs_gitlab> @jeff-hykin pretty unrealistic actually from what I understand
<FromGitter>
<anicholson> @jeff-hykin wasm probably more likely than C, but yeah, it's hard
<FromGitter>
<dscottboggs_gitlab> Go recently managed to get a working WASM port, which they "hadn't yet optimized for size" that was over 2MB
<FromGitter>
<dscottboggs_gitlab> which is kinda pointless
<FromGitter>
<dscottboggs_gitlab> the point is that you have to statically link the whole crystal stdlib which is going to be huge.
<FromGitter>
<dscottboggs_gitlab> plus several other libraries
<FromGitter>
<jeff-hykin> Thanks @dscottboggs_gitlab and @anicholson , I was what was afraid that was the case.
<FromGitter>
<dscottboggs_gitlab> although
<FromGitter>
<dscottboggs_gitlab> if size isn't a concern it is feasible
<FromGitter>
<dscottboggs_gitlab> it would take a lot of work though
<FromGitter>
<anicholson> step 0 (for wasm) would be a WASM version of the GC
<FromGitter>
<dscottboggs_gitlab> I'm pretty sure I read that compiling the actual code wasn't a huge problem because LLVM can compile to WASM
<FromGitter>
<jeff-hykin> I dont know a ton about converting to webassembly, but if crystal ever gets there i was going to be looking into making api bindings for browser environments
<FromGitter>
<anicholson> yeah, it's the C libraries the stdlib relies on, like `libevent`, the GC, etc.
<FromGitter>
<anicholson> they're the work
<FromGitter>
<proyb6> @Blacksmoke16 I assume the body_io is applicable for HTTP server as well?
<FromGitter>
<jeff-hykin> really? @anicholson I though c could be compled to wasm
<FromGitter>
<anicholson> it can
<FromGitter>
<anicholson> I guess it's a question of linking
<FromGitter>
<anicholson> don't get me wrong, I'd love it to happen
<FromGitter>
<jeff-hykin> Ah okay. Do you think theres any opportunity for a generic way for crystsl to call wasm-ified c libaries? Or is it pretty much going to need a custom call to each tool in the stl
<FromGitter>
<anicholson> not sure, @jeff-hykin . I'm speaking from intuition & first principles rather than Actual Knowledge ;)
marmotini_ has joined #crystal-lang
<FromGitter>
<anicholson> I guess there's a difference between the Crystal compiler toolchain and the programs it produces
<FromGitter>
<jeff-hykin> haha okay 👍 thanks for the insight though
<FromGitter>
<anicholson> theoretically there's nothing stopping someone from compiling every C lib needed by the Crystal stdlib to WASM. If you could do that, and wire the linking together properly a la `emscripten`, then it's feasible for a purely-Crystal program to be compiled to WASM via LLVM too.
<FromGitter>
<anicholson> and even more hypothetically, if you solved that problem, then it's no different to C libs in userland Crystal programs. You'd need to have access to the C source though
rohitpaulk has joined #crystal-lang
* FromGitter
* anicholson goes off to attempt to compile `libevent` to WASM
<FromGitter>
<jeff-hykin> Haha 👌 i'll check back here in a month. Maybe convince one of the devs at mozilla to help out. Cross compatible Crystal would be pretty nice, and replacing javascript with crystal would be incredible even with no relative performance benefits.
<FromGitter>
<anicholson> well, `libevent` compiled to WASM okay with a tweak
marmotini_ has quit [Ping timeout: 240 seconds]
<FromGitter>
<anicholson> `bdwgc` not so much
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter>
<bew> @fenicks did you manage to use `select`?
<FromGitter>
<fenicks> @bew Yes `select` works as I was expected
rohitpaulk has joined #crystal-lang
<FromGitter>
<mettuaditya> can anyone suggest how to implement graphs in crystal
<FromGitter>
<mettuaditya> like for DFS and BFS
rohitpaulk has quit [Ping timeout: 264 seconds]
<FromGitter>
<yxhuvud> Uh, you basically only need a way to find neighbours of the current choice to search like that.
<FromGitter>
<m-o-e> migrating the brain from ruby to crystal is funny. i almost always reach for a macro first, and then realize a different, less obtuse way to do it.
<FromGitter>
<m-o-e> loving the way json/yaml mapping works
<FromGitter>
<bararchy> @m-o-e What are yyou migrating?
<FromGitter>
<m-o-e> @bararchy my brain! (it was just a general remark about the process of learning crystal ;))
<FromGitter>
<bararchy> Ohhh ok lol
<FromGitter>
<m-o-e> it's very pleasant. i think the only thing i'm really missing so far is a way to access props by name.
<FromGitter>
<alehander42> whatever your usecase is for that, it's probably possible to simulate it with compile time metaprogramming
<FromGitter>
<m-o-e> i assume you're referring to macros? yes, those are possible, but sadly tend to become ugly. a basic use-case that i've run into a few times now is: mapping a yaml/json-hash and then iterating over the top-level keys.
<FromGitter>
<bararchy> @m-o-e we created some recursive logic to iterate over a whole JSON which is outputted via JSON.parse and extract key-value. then you you are able to change each one and re-build it with the different data inside
<FromGitter>
<m-o-e> barisbalic: yes, that sounds similar to my current approach: parse, an inject a root-node, then apply mapping to the result
<FromGitter>
<m-o-e> but that isn't very pretty, and requires to parse the input twice
<FromGitter>
<m-o-e> i think life would be easier there if #mapping wouldn't only add getters/setters, but also a generic get_property()
<FromGitter>
<m-o-e> (but i'm still new to crystal, maybe this wouldn't be idiomatic or create problems in ways that i don't grasp yet)
<FromGitter>
<bew> Yes probably
<FromGitter>
<bew> Btw the json/yaml (de) serialization don't necessarily use the mapping macros anymore, checkout `JSON::Serializer` in the docs
<jokke>
not sure if i've asked this before but is it possible to define macro methods without having to recompile crystal?
<jokke>
i'm having real trouble to keep things readable when writing more complex macros
<FromGitter>
<bew> Not possible
<jokke>
dang :/
<FromGitter>
<bew> You could call other macros though, but keep in mind that the code must be valid
<FromGitter>
<bew> For each macros
<FromGitter>
<Istanful> Hi! In my application I want to import JSON in one format and output JSON in another. I find that the `JSON.mapping` macro is useful, however I can't find a nice way to output with another mapping than the original. ⏎ ⏎ Given that I have `{ "cake": "nom" }` and want to output it as `{ "Cake":"nom" }` it would be nice if I could do something like `Downcased.from_json("{ "cake": "nom"
<FromGitter>
... }").to_json(Upcased::JSON_MAPPING)`. Is something similar to this possible?
<FromGitter>
<bajro17> I have problem with connection to database
<FromGitter>
<bajro17> where to put password
<z64>
@Istanful not entirely clear what your use case is, but you have one or two options. the first is to define `#to_json(builder)` and write the serialization yourself. another, is if you don't actually need the lower-cased input (just the Cased output) is you can use the `key` option in JSON.mapping https://carc.in/#/r/5bjf
zorp has joined #crystal-lang
<z64>
that said - there isn't a high level control for that kind of thing
<z64>
a tangent, but also take a look into JSON::Serializable - you might find it more powerful for certain use cases https://carc.in/#/r/5bjk
<FromGitter>
<bajro17> I find solution
<z64>
@bajro17 typically you specify a connection URI to something like `DB.connect` or `DB.open`; the format of it depends on the database you are using, but in postgres for example it is `postgresql://user:secret@localhost
<FromGitter>
<hello2dj> I am a newbie , When i need inherit a class or include a module?
<FromGitter>
<hello2dj> thank you
<FromGitter>
<Istanful> @FromIRC Thing is I don't want to define a custom builder. Coming from ruby land that seems excess since I already know all the getters. :)
<FromGitter>
<j8r> @hello2dj to DRY (don't repeat yourself)
<FromGitter>
<Istanful> @z64 Thing is I don't want to define a custom builder. Coming from ruby land that seems excess since I already know all the getters. :)
<z64>
@Istanful the problem is the JSON.mapping / JSON::Serializable does not expose any means to control how the *keys* are written, only the *values*. its not a semantic it recognizes (case insensitive keys)
<z64>
you can maybe write a custom macro though for a basic object..
<FromGitter>
<Istanful> @z64 Yeah the macro is the one solution I could come up with. Though that feels overkill I think
<FromGitter>
<Istanful> @z64 I will go for the `to_json(builder)` solution I think. Thanks for the help!
<FromGitter>
<hello2dj> thank you so much, but what the difference between inherit class and include module?
<z64>
@hello2dj well mechanically for one, inheritance will add *both* class *and* instance methods (`Foo.bar` and `foo.bar`) to your type. beyond that, i know this is for ruby, but all of the semantics / practices described in this answer apply well to crystal: https://stackoverflow.com/questions/1282864/ruby-inheritance-vs-mixins
<z64>
(woops, forgot to finish: `include SomeModule` will just add instance methods `foo.bar`)
<FromGitter>
<j8r> I'm working on a new configuration/object notation: `con` (Cretin Object Notation) written in Crystal, of course ⏎ What do you think of this type of syntax - any suggestions? ⏎ ⏎ ```code paste, see link``` ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5bd07a10c08b8b3067664a2e]
<FromGitter>
<j8r> the delimiters for each token are either ` ' ', '\n', '\t', '\r'`
<FromGitter>
<Prutheus> I am using jennifer.cr …. I have a Relational Object called Search. A user has_many searches. Now I want to modify a search by that: ⏎ ⏎ ` ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=5bd07a86ae7be94016ab55df]
<FromGitter>
<Prutheus> it does a transaction but dont write to db … why?
marmotini_ has joined #crystal-lang
<FromGitter>
<Blacksmoke16> not sure
<FromGitter>
<Prutheus> I need to solve that fast, the server i am working on are changed to jennifer and down cause i can’t modify my data … please help me
<FromGitter>
<Blacksmoke16> try doing `search.save!` and see what the exception is
<FromGitter>
<Prutheus> it rescues on the line `search.save!` with `Object is invalid: []`
<FromGitter>
<Blacksmoke16> least you got a clue now
<FromGitter>
<Prutheus> no really, i do not understand. but for sure, the validation fails
thews has joined #crystal-lang
<FromGitter>
<bew> @j8r I'd suggest to remove the FromString version, and only keep one from IO, you can make a IO::Memory from a String object
<FromGitter>
<j8r> I'll rather use the second one with `<`` >`
<FromGitter>
<j8r> another option is using quotes
sz0 has joined #crystal-lang
<FromGitter>
<dscottboggs_gitlab> I'm not being sarcastic. what is the benefit of that over JSON, YAML, or TOML?
<FromGitter>
<j8r> This is even simpler than JSON, and more readable than JSON (and even YAML IMHO)
<FromGitter>
<dscottboggs_gitlab> computationally simpler you mean?
<FromGitter>
<j8r> Maybe, haven't tested - I think it will be very close. Simpler for the user to read and write
<FromGitter>
<j8r> like YAML, but YAML is sometimes hard to follow when there are deep key/values
<FromGitter>
<dscottboggs_gitlab> So I'm confused about the delimiters in your Hash. everything else is separated by spaces or newlines or tabs, but that appears to have only a multi-line syntax
<FromGitter>
<dscottboggs_gitlab> how would it know what ⏎ `hash { key "value" other "value" }` meant?
<FromGitter>
<dscottboggs_gitlab> also are unquoted strings supposed to be special-case strings or are they like symbols?
<FromGitter>
<j8r> that's only key/value
<FromGitter>
<j8r> keys aren't quoted, strings are quotes
<FromGitter>
<dscottboggs_gitlab> so no delimiter chars allowed in keys then?
<FromGitter>
<j8r> you can escape them
<FromGitter>
<dscottboggs_gitlab> hm
<FromGitter>
<j8r> I general, having spaces and special symbols in keys are rare, and not recommended. But you can still do
<FromGitter>
<dscottboggs_gitlab> fair
<FromGitter>
<j8r> The same for the in line Hash you have put as example. You can do, the parser won't complain, but in general better to do it in multi line 😄
<FromGitter>
<dscottboggs_gitlab> true
<FromGitter>
<dscottboggs_gitlab> just wondering about how the notation itself worked
<FromGitter>
<r00ster91> When I use `STDIN.raw` and for example suddenly "hello" is coming from somewhere to STDIN, how do I just read the "hello" and then go on? ⏎ I don't want to use `gets` because it requires a delimiter but I don't know if the string will even contain the delimiter. I also don't want to use any method that requires me to say the bytesize of the string (like `read_string`) because I don't know that either. And I
<FromGitter>
... tried `gets_to_end` doesn't do anything and just hangs the program. ⏎ ⏎ Can I do this somehow? I'm pretty much searching for a string version of `read_char` which just reads what currently arrived to STDIN and then goes on [https://gitter.im/crystal-lang/crystal?at=5bd08ec06e5a401c2dc2f0cf]
<FromGitter>
<j8r> It should work for any new 2.x versions AFAIK @dscottboggs_gitlab
<FromGitter>
<dscottboggs_gitlab> I've got two versions of libgc on my system, when I run `whereis libgc` I get the right version though, do you think crystal/llvm is still grabbing the wrong one?
<FromGitter>
<dscottboggs_gitlab> just trying to figure get crystal to compile
<FromGitter>
<j8r> I don't know, what's the error?
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
<FromGitter>
<dscottboggs_gitlab> nope I uninstalled the distro version of libgc so it's not that...
akaiiro has joined #crystal-lang
<FromGitter>
<j8r> the `-dev`?
<FromGitter>
<dscottboggs_gitlab> yeah, both, and double-checked all the dependencies are installed. I guess I'll raise an issue and build in docker on 16.04 for now unless you have a better suggestion
DTZUZU has quit [Read error: Connection reset by peer]
return0xe has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
<FromGitter>
<j8r> yes, on my side I only build the compiler in an Alpine Docker container :)
Creatornator has joined #crystal-lang
<FromGitter>
<bew> @r00ster91 how do you know there is `hello` coming and not `h` `e` `l` `l` `o` ?
non-aristotelian has joined #crystal-lang
<FromGitter>
<r00ster91> I'm just pretty sure that I'm getting it in one string instead of multiple chars
<FromGitter>
<bew> this doesn't make sense, there is no concept of strings when you're reading it
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<r00ster91> ooh.. so everything comes in single chars. that's good to know
<FromGitter>
<enra4> i get this weird error when trying to run crystal on another account than root ⏎ `` ⏎ host@arnesify:~$ crystal ⏎ Failed to raise an exception: END_OF_STACK ⏎ [0x7f8aadd1b746] ??? ... [https://gitter.im/crystal-lang/crystal?at=5bd0ac7b82893a2f3b3340f9]
<FromGitter>
<enra4> this is `0.26.1` didnt happen on the last version of crystal i was on, which i think was `0.25.?`
<FromGitter>
<dscottboggs_gitlab> you have to be *root* to run crystal??
<FromGitter>
<dscottboggs_gitlab> that's weird
<FromGitter>
<enra4> i also think its very weird lol
<FromGitter>
<dscottboggs_gitlab> what's the output of `ls -la $(which crystal)`?
<z64>
note the last comment, rx14 marked it as a duplicate of another general issue that isn't specific to containers
<FromGitter>
<enra4> i see now, thanks!
<FromGitter>
<dscottboggs_gitlab> @j8r thank you
<FromGitter>
<fusillicode_twitter> Hi guys, sorry for the bother but why can't I find the duplicates of a list of strings in this way? `(list_of_strings - list_of_strings.uniq).uniq`
Creatornator has joined #crystal-lang
<FromGitter>
<fusillicode_twitter> I actually get an empty array as a results 🤔
<FromGitter>
<straight-shoota> @fusillicode_twitter Because you're removing all items of `list_of_strings`. All occurences of the items in `list_of_strings.uniq` will be removed.
<FromGitter>
<fusillicode_twitter> mmm
<FromGitter>
<straight-shoota> What exactly do you expect?
<FromGitter>
<fusillicode_twitter> uhm actually just the duplicates values 🤔
<z64>
they expected `["a", "a"] - ["a"]` to remove a single occurence of `"a"` :p
<FromGitter>
<vladfaust> changing/removing timeout doesn't change things
<FromGitter>
<vladfaust> Huh, that's a small context, I guess. I'm halting a docker process with Tarantool DB instance exposing to 3001 in the near terminal tab, and crystal process just hangs
<FromGitter>
<vladfaust> Adding `sleep 0` does raise on the halt
<FromGitter>
<straight-shoota> I'd guess that `read_fully?` does short-curcuit somehow so you're effectively in a tight loop
<FromGitter>
<vladfaust> Should it be replaced with something?
<FromGitter>
<vladfaust> Sorry, afk 20 mins
zorp_ has joined #crystal-lang
marmotini has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tilpner_ has joined #crystal-lang
dostoyev1ky has joined #crystal-lang
marmotini_ has quit [*.net *.split]
zorp has quit [*.net *.split]
Flipez has quit [*.net *.split]
johndescs has quit [*.net *.split]
tilpner has quit [*.net *.split]
pabs has quit [*.net *.split]
dostoyevsky has quit [*.net *.split]
rohitpaulk has joined #crystal-lang
commavir has quit [*.net *.split]
tilpner_ is now known as tilpner
johndescs has joined #crystal-lang
Creatornator has joined #crystal-lang
Flipez has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 272 seconds]
<FromGitter>
<vladfaust> Uh, okay
<FromGitter>
<vladfaust> So, adding `sleep 0` is the best and the most performant way to read exactly 5 bytes from the socket, right?
<oprypin>
lol what
Jenz has joined #crystal-lang
<oprypin>
after a long investigation, i see nothing wrong with the code and i see no reason why it would require sleep 0
<oprypin>
read_fully calls read which should be blocking
<oprypin>
if read is somehow not blocking, then yes, this is a problem
<oprypin>
vladfaust, no, you know what the problem is? if `read_fully?` returns `nil` once, it will always return `nil` in all subsequent calls
<oprypin>
and instantly, too
<oprypin>
not sure what this `@open` is supposed to mean but the right way to write this would be while @socket.read_fully?(slice)
<oprypin>
cc @straight-shoota
<FromGitter>
<straight-shoota> Okay. I wasn't sure if subsequent calls would short-circuit
<FromGitter>
<vladfaust> The socket can be closed manually (`my_conn.close`), so `@open` is required
<oprypin>
for a socket, `read` instantly returns 0 if and only if the socket is closed, and so `read_fully` also instantly returns. causing a busyloop
<oprypin>
you can certainly write `while @open && read_fully`
<FromGitter>
<vladfaust> I wasn't aware of the concept of busyloops and short-circuit
<oprypin>
but it's possible that @open is not necessary
<FromGitter>
<vladfaust> Is there a way to *wait* without blocking unless 5 bytes are read?
<oprypin>
read_fully does that
<FromGitter>
<vladfaust> read_fully differs from read_fully?, right
<oprypin>
i'm just treating them as the same thing
<FromGitter>
<vladfaust> Hm. Is there a way to wait without blocking unless 5 bytes are read and do not raise a error?
<oprypin>
"wait" and "blocking" are interchangeable in my current vocabulary
<FromGitter>
<vladfaust> Yep, makes sense
<FromGitter>
<vladfaust> Okay, is there a way to wait for 5 bytes read without errors and minumum impact on performance, i.e. allowing other fibers to run?
<oprypin>
`read_fully?` waits until it has read 5 bytes. for the case of socket, it returns `nil` (instantly) if and only if the socket is closed
<FromGitter>
<vladfaust> And if it's not closed but there are no 5 bytes of data (its empty), what's then?
<oprypin>
then it blocks because it uses `read` which blocks
<oprypin>
`read_fully?` in a loop works well but you must not loop on it after it has returned `nil` for the first time because THAT'S the busyloop
<FromGitter>
<vladfaust> Aaaaah
<oprypin>
and by "blocks" i mean "waits" , and other fibers work well
<FromGitter>
<vladfaust> Now I understand
<FromGitter>
<vladfaust> Wow. Thank you so much for the explaination, @oprypin
<FromGitter>
<vladfaust> Really, appreciate that :)
<oprypin>
i learned something too. i didn't know that `read_fully` exists so I would have basically reimplemented it myself if I needed this functionality
<FromGitter>
<fusillicode_twitter> @dscottboggs_gitlab you're too kind 😅
<FromGitter>
<vladfaust> You know what, I think the question is still here. Why `puts` or `sleep` leads to a error raise?
<FromGitter>
<vladfaust> Why not putting or sleeping forever if `read_fully?` just returns `nil`?
<FromGitter>
<vladfaust> And when busylooping, it has no time to check for a timeout?
<oprypin>
i'd like to see a complete program
<oprypin>
but i'll be afk for a while
<FromGitter>
<straight-shoota> > And when busylooping, it has no time to check for a timeout? ⏎ ⏎ exactly
<FromGitter>
<vladfaust> @oprypin, it would take time because it's third party DB. @straight-shoota seems to confirm my guess
<FromGitter>
<vladfaust> Okay, I'm glad we've figured that out :) Thanks again, guys
<FromGitter>
<straight-shoota> Crystal's scheduler is cooperative, that means a fiber must explicitly yield control. If it's in a tight loop, there is no way for a different fiber to jump in. And the exception is obviously raised in a different fiber.
<Jenz>
I love how crystal does its fibers :D
<jokke>
is there any specific reason why to_json(JSON::Builder) isn't defined for enumerable?
<jokke>
uh sorry
<jokke>
makes sense
<Jenz>
A default Enumerable#to_json would make some sense IMO
<jokke>
nah
<jokke>
Hash is also enumerable
<jokke>
and yields key-value-pairs
<Jenz>
Yeah, true
dostoyev1ky is now known as dostoyevsky
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Creatornator has joined #crystal-lang
Jenz has quit [Quit: 'Night']
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Creatornator has joined #crystal-lang
<jokke>
i have a question about crystal-db. in the .from_rs method in the db mapping an array is returned. i see how this seems necessary because the result set has to be closed. Would the following however also work: return an iterator over the result set which closes the result set in its finalize method?
<jokke>
this would delay closing it until the gc strikes but maybe that's not a problem?
<jokke>
always creating an array for results will consume a lot of unnecessary memory for large result sets and also iterate twice over the results (first to create the array and later to iterate over it in the application)
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Creatornator has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Creatornator has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
marmotini has quit [Remote host closed the connection]
Creatornator has joined #crystal-lang
zorp_ has quit [Ping timeout: 244 seconds]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Creatornator has joined #crystal-lang
<FromGitter>
<Blacksmoke16> https://play.crystal-lang.org/#/r/5btg shouldn't the type of `t` in this be only `Int32` since there was a nil check in super?
<FromGitter>
<Blacksmoke16> nvm, because the return in there is prob getting passed down to the sub method
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]