RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.0 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
Renich has left #crystal-lang [#crystal-lang]
Renich has joined #crystal-lang
non-aristotelian has quit [Quit: non-aristotelian]
non-aristotelian has joined #crystal-lang
johndescs has quit [Ping timeout: 268 seconds]
johndescs has joined #crystal-lang
Renich has left #crystal-lang [#crystal-lang]
Renich has joined #crystal-lang
<FromGitter> <proyb6> I want to try if I could replace certain string of bytes in all occurrence ⏎ ⏎ "Apple orange apple".to_slice
ua has quit [Ping timeout: 250 seconds]
ua has joined #crystal-lang
akaiiro has quit [Ping timeout: 250 seconds]
akaiiro has joined #crystal-lang
rohitpaulk has joined #crystal-lang
jemc has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
DTZUZU has quit [Quit: WeeChat 2.2]
DTZUZU has joined #crystal-lang
lvmbdv has quit [Quit: WeeChat 1.5]
lvmbdv has joined #crystal-lang
<FromGitter> <Coalpha> Hello all. "https://crystal-lang.org/api/0.27.0/" is blocked at the network level at my school. Is there any way that I can save a copy of these pages on my computer?
<FromGitter> <icyleaf> Swagger for Crystal released v0.1.0 preview https://github.com/icyleaf/swagger ⏎ it could not unmarshal struct and class for now, i do not know how to reflect and here has some similar technology in other language: ⏎ Go: https://golangbot.com/reflection/ ⏎ Swift: https://medium.com/@swiftthesorrow/reflection-in-swift-958824116b07 [https://gitter.im/crystal-lang/crystal?at=5bfce9f16621313894258b19]
<FromGitter> <icyleaf> @Coalpha Try https://devdocs.io/crystal/
<oprypin> Coalpha: http://pryp.in/crystal
<FromGitter> <Coalpha> Oh sweet, I didn't know devdocs had crystal
<FromGitter> <Coalpha> Thanks!
<FromGitter> <Coalpha> also, thanks, oprypin
jemc has quit [Ping timeout: 250 seconds]
<FromGitter> <bararchy> @icyleaf that's really good! thanks for the update, maybe publish it via crystal-ANN
<FromGitter> <j8r> @bararchy I remember you was asking questions about class vs structs, there is now https://crystal-lang.org/docs/syntax_and_semantics/structs.html
<FromGitter> <j8r> I'll release a new Clicr version with help align
<FromGitter> <bararchy> @j8r that's great! updated, thanks :)
ashirase has quit [Ping timeout: 246 seconds]
<FromGitter> <bararchy> is there a way to disable the trace under the help output?
ashirase has joined #crystal-lang
<jokke> omg i didn't know devdocs existed.
<jokke> mind blown
<FromGitter> <dscottboggs_gitlab> @Coalpha on my computer the documentation is stored at `/usr/share/doc/crystal/api/index.html` Seems a little silly to block documentation, but maybe they just whitelist? that sucks dude.
<FromGitter> <j8r> @bararchy you have to rescue the exception, please see https://github.com/j8r/clicr#error-handling
<FromGitter> <j8r> Before it was done with `puts help` and `exit` instead of raise, but this wasn't testable and not flexible (can't change the stdout)
<FromGitter> <drum445> Anyone know why I might be getting this on my server when running a release binary? ⏎ ```./crystal_rest: /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1: version `OPENSSL_1_1_1' not found (required by ./crystal_rest)```
<FromGitter> <proyb6> Who is good in C++?
<FromGitter> <j8r> I've a spec failing in a Docker container ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bfd36537074b9036862aa44]
<FromGitter> <j8r> Int32...
<FromGitter> <j8r> how can I debug this?
<FromGitter> <j8r> Any clue? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bfd40dc7d26db1e8303911b]
<FromGitter> <j8r> to reproduce: `git clone https://github.com/DFabric/apps-static; cd apps-static; ./build-static.sh dppm-static x86-64` :|
<FromGitter> <j8r> it may be due to the alpine system, libressl/openssl dunno
<FromGitter> <j8r> yeah this was libressl-dev
<FromGitter> <bararchy> lol
<FromGitter> <j8r> Beware everybody, Alpine is switching back to OpenSSL from LibreSSL
<FromGitter> <bararchy> 3rd party bugs are the worst
<FromGitter> <f1refly_gitlab> hmm
<FromGitter> <j8r> that's because of https://github.com/alpinelinux/aports/pull/5560#issuecomment-436791090 , but apparently the switch isn't finished
<FromGitter> <j8r> @bararchy you have done the rescue to avoid the backtrace for the help?
<FromGitter> <bararchy> @j8r ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bfd469a375c40294bacb4c4]
<FromGitter> <bararchy> now it won't show help atall
<FromGitter> <j8r> it does
<FromGitter> <bararchy> Oo
<FromGitter> <bararchy> what am I missing lol
<FromGitter> <bararchy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bfd48662f1872707ae06789]
<FromGitter> <bararchy> wont print anything
<FromGitter> <bararchy> Oh! `self` ffs
<FromGitter> <bararchy> haha
<FromGitter> <bararchy> nice! thanks @j8r
<FromGitter> <f1refly_gitlab> Wait a sec you guys
<FromGitter> <f1refly_gitlab> is this syntax documented somewhere?
<FromGitter> <bararchy> what syntax?
<FromGitter> <f1refly_gitlab> I didn't read about this in the 'learn' section of the crystal-lang page
<FromGitter> <j8r> @bararchy you could juste squash&merge for suck simple commit (too late)
<FromGitter> <f1refly_gitlab> The descriptive declaration type thing in your repo
<FromGitter> <bararchy> `a : String` ?
<FromGitter> <bararchy> etc..
<FromGitter> <f1refly_gitlab> [class].create([json-syntax... i think?])
<FromGitter> <bararchy> Oh, it's named arguments
<FromGitter> <bararchy> and I guess some namued-tuples as params
<FromGitter> <j8r> It called a NamedTuple (https://crystal-lang.org/api/master/NamedTuple.html). The shard used is https://github.com/j8r/clicr
<FromGitter> <j8r> In fact it could also be a `Hash`
<FromGitter> <f1refly_gitlab> Ah, so it's a shard thing
<FromGitter> <f1refly_gitlab> sorry
<FromGitter> <j8r> This also used in stdlib
<FromGitter> <j8r> https://crystal-lang.org/api/master/JSON.html#mapping%28_properties_%2Cstrict%3Dfalse%29-macro
<FromGitter> <f1refly_gitlab> I know about the used datatypes, i was just confused about the way the programs parameters were "described" in his sourcecode
<FromGitter> <j8r> undertheground it's a macro that iterates on this values
<FromGitter> <bew> @proyb6 define good :) what do you need?
<FromGitter> <f1refly_gitlab> I thought he'd tried to create a class named 'Clicr' and wasn't aware that it's a shard he was using
<FromGitter> <f1refly_gitlab> Sorry
<FromGitter> <f1refly_gitlab> @j8r That shard looks incredibly useful, great job!
<FromGitter> <j8r> @f1refly_gitlab thanks. Little example to show what's done https://carc.in/#/r/5mv8
<FromGitter> <f1refly_gitlab> yeah, thank you :)
jemc has joined #crystal-lang
jemc has quit [Client Quit]
jemc has joined #crystal-lang
<FromGitter> <greenbigfrog> I'm somehow running into ```gmp: overflow in mpz type ⏎ Program received and didn't handle signal IOT (6)``` when trying to divide `10_big_d / 1_big_d` ⏎ I can't repro elsewhere though...
<jokke> any idea where this error might come from? Failed to raise an exception: END_OF_STACK
<FromGitter> <proyb6> @bew https://oatpp.io/benchmark/digital-ocean
<FromGitter> <proyb6> I just came across this and what you think it could be useful for Crystal in a cloud?
<FromGitter> <proyb6> I mean we know async networking could be useful for cloud
<FromGitter> <greenbigfrog> ```code paste, see link``` ⏎ ⏎ Somehow I'm getting the overflow on the second division... [https://gitter.im/crystal-lang/crystal?at=5bfd63978dffd748dbef5cf5]
<FromGitter> <greenbigfrog> smh the `a/b` creates a over 3 GB large number when output written to a file...
<FromGitter> <greenbigfrog> got a temp fix figured out
<FromGitter> <greenbigfrog> somehow those numbers have a crazy scale
<FromGitter> <greenbigfrog> hm. it appears to happen when BigDecimal has a unneccesary huge scale
<FromGitter> <greenbigfrog> eg scale of 8, even when a scale of 2 would be sufficient...
Vexatos has joined #crystal-lang
akaiiro has quit [Ping timeout: 250 seconds]
akaiiro has joined #crystal-lang
DTZUZO has quit [Quit: WeeChat 2.0]
DTZUZO has joined #crystal-lang
jemc has quit [Quit: WeeChat 2.2]
moei has joined #crystal-lang
<FromGitter> <proyb6> How do I "chain" multiples API to a variable if includes? conditions found it included a valid string?
<FromGitter> <proyb6> Like I want to remove all HTML elements
Renich has quit [Quit: Renich]
Renich has joined #crystal-lang
red_menace has joined #crystal-lang
red_menace has quit [Client Quit]
<FromGitter> <greenbigfrog> How print all class vars of an Object for debugging purposes?
<FromGitter> <vladfaust> https://carc.in/#/r/5myd should work, but does not
<FromGitter> <greenbigfrog> thanks
<FromGitter> <Blacksmoke16> its because `@type.instance_vars` only works in context of a method
<FromGitter> <vladfaust> Try to move `.instance_vars` around, maybe you'll get lucky
<FromGitter> <vladfaust> Still https://carc.in/#/r/5myn
<FromGitter> <vladfaust> Nope https://carc.in/#/r/5myp
<FromGitter> <Blacksmoke16> yea i dont think you an get class vars using that
<FromGitter> <redcodefinal> Hey is there anyway to use a non-blocking version of `IO#receive`? I need to read from a UDP socket without blocking.
<FromGitter> <vladfaust> You could `spawn` it
<FromGitter> <redcodefinal> I already do but the spawn won't release the socket when it blocks
<FromGitter> <vladfaust> Ah, this one. Sorry, have no knowledge in this
<FromGitter> <redcodefinal> The issue is that `data_sock` blocks using `data_sock.receive`, and won't release the fiber when shutting down the server, so if I try to shut it down and restart it the sockets won't bind.
<FromGitter> <vladfaust> `socket.close`?
<FromGitter> <redcodefinal> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bfd88c1958fc53895fb7686]
<FromGitter> <redcodefinal> Thats whats crazy, it is completely happy to continue blocking after the close
<FromGitter> <redcodefinal> This is the log.
<FromGitter> <redcodefinal> On line 39 it closes the server, it could have only gotten to that point if the socket closed right? Even if the socket was in the middle of a blocking receive it should have killed the socket and caused an exception.
<FromGitter> <redcodefinal> I was hoping I could find an answer similar to Ruby's `recv_nonblock` which produces a `Errno::EWOULDBLOCK.`
<FromGitter> <redcodefinal> Here is a listing of the complete code. https://gist.github.com/redcodefinal/d58d31ce820d1435133d282a494e33c1
rohitpaulk has joined #crystal-lang
Renich has left #crystal-lang [#crystal-lang]
Renich has joined #crystal-lang
<FromGitter> <redcodefinal> Maybe there is a way to specifically shut down a Fiber? I noticed spawn can take a `name : String`. Is there any way to search through or capture the fiber in a variable?
<FromGitter> <vladfaust> I'm sorry, I don't know that
<FromGitter> <kinxer> @redcodefinal spawn (https://crystal-lang.org/api/0.27.0/toplevel.html#spawn%28%2A%2Cname%3AString%3F%3Dnil%2C%26block%29-class-method) returns the fiber. However, I don't see a way to stop a fiber in the Fiber documentation (https://crystal-lang.org/api/0.27.0/Fiber.html).
asterite has quit [Quit: Bye]
jhass has quit [Quit: Bye]
asterite has joined #crystal-lang
jhass has joined #crystal-lang
<FromGitter> <redcodefinal> I didn't see anything about a `recv_nonblock` style feature in `IO`, `Socket`, or `UDPSocket`
Renich_ has joined #crystal-lang
Renich has quit [Ping timeout: 272 seconds]
Renich_ is now known as Renich
<FromGitter> <redcodefinal> @kinxer I'm looking in the docs and found `Fiber#resume` and `Fiber#run`. No docs on them. What do they do? It seems like when you use either of them it ignores every `Fiber.yield` call inside the spawn block.
<FromGitter> <bew> well, no docs on them because you're not suppose to use them directly
<FromGitter> <redcodefinal> Ah I see
<FromGitter> <bew> there is no `Fiber#close` yet, but I remember reading a discussion about it not so long ago, don't remember the results though
<FromGitter> <bew> somewhere in the multithread preparation PRs
<FromGitter> <bew> iirc
<FromGitter> <redcodefinal> I'll take a look around the PRs and see what people have come up with.
<FromGitter> <redcodefinal> The best solution right now is kind of a dumb one
<FromGitter> <redcodefinal> Instead of trying to get a nonblock recv or killing the fiber, instead I'll just send \x00 to the socket which will unblock it.
Renich_ has joined #crystal-lang
Renich has quit [Ping timeout: 250 seconds]
Renich_ is now known as Renich
<FromGitter> <redcodefinal> Wow even after closing the port, killing the fibers behind them, it still says I can't rebind the port :<
<FromGitter> <redcodefinal> Ok I fixed it and I'm not sure why lol
rohitpaulk has quit [Ping timeout: 268 seconds]
Renich has quit [Read error: Connection reset by peer]
Renich has joined #crystal-lang
<FromGitter> <greenbigfrog> Is it intentional that something like ` while (a, b = true) && true == false` fails with `unterminated parenthesized expression`?
<FromGitter> <bew> Hum.. The error is misleading
<FromGitter> <bew> But it should error something
<FromGitter> <bew> What's that `a` doing here?
Renich has quit [Read error: Connection reset by peer]
Renich has joined #crystal-lang
<FromGitter> <greenbigfrog> this is just an example
<FromGitter> <kinxer> Are you trying to assign `a` and `b` to `true`?
<FromGitter> <kinxer> @redcodefinal If you figure out what was wrong, I'd be interested to know what it is. No worries if you don't figure it out, though.
<FromGitter> <greenbigfrog> `while (div, mod = value.divmod(10)) && mod == 0` is what I was actually doing...
<FromGitter> <kinxer> Extract the `while` condition to a method, maybe?
<FromGitter> <kinxer> I assume `#divmod` is returning twice, and it seems like there should be some error when testing the truthiness of multiple return values.
Renich_ has joined #crystal-lang
Renich has quit [Ping timeout: 250 seconds]
Renich_ is now known as Renich
<FromGitter> <bew> @kinxer it does not return twice, it returns a tuple
<FromGitter> <kinxer> Oh. Which should be truthy, yes?
<FromGitter> <bew> Not sure you can 'unpack' a tuple like that in an inline way like this, for example what should be the return value of this expression?
<FromGitter> <bew> Yeah that's the issue: https://carc.in/#/r/5n1b
<FromGitter> <bew> You can open an issue about that in the Crystal repo if you want :)
<FromGitter> <kinxer> Unrelated, can macros access the generic type `T` of a generic class?
<RX14> yes
<RX14> if they're in a method
<FromGitter> <kinxer> Thanks, @RX14
<RX14> np
<FromGitter> <greenbigfrog> thanks benjamin and benoit
<FromGitter> <redcodefinal> @kinxer I have been working since I fixed it to reproduce what I was experiencing and I still have not.
moei has quit [Quit: Leaving...]
<FromGitter> <kinxer> I'm trying to serialize a class that contains an array of objects inheriting from an abstract class, as follows: ⏎ ⏎ ```abstract class A``` [https://gitter.im/crystal-lang/crystal?at=5bfdcac6f048fa105132d927]
<FromGitter> <jemc> Are there any other language projects in the crystal community that, like mine, are using crystal to compile LLVM? If so, I might like to peek at some of how they're handling certain things
<FromGitter> <jemc> So far Crystal + LLVM has been a really nice experience, other than a few pain points that there might be existing solutions to.
<FromGitter> <jemc> I imagine that being self-hosted has really sanded a lot of the rough edges off the LLVM library, since I've been impressed so far
OvermindDL1 has joined #crystal-lang
Renich_ has joined #crystal-lang
Renich has quit [Ping timeout: 240 seconds]
Renich_ is now known as Renich
<FromGitter> <proyb6> How do you chaining gsub API in this each time includes found a valid string to avoid expensive operation? ⏎ ⏎ V = "Apple orange apple" ⏎ V.gsub(...).gsub(...)... [https://gitter.im/crystal-lang/crystal?at=5bfdd6a07d26db1e83079b48]
<FromGitter> <proyb6> If I have hundred of search and replace