RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.1 | 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
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ca951c9f851ee043d74674b]
<FromGitter> <Blacksmoke16> hm
<FromGitter> <Blacksmoke16> only happens when i have a command that *doesnt* new up a config object..
<FromGitter> <Blacksmoke16> :thinking:
_whitelogger has joined #crystal-lang
tsundsted has quit [Ping timeout: 256 seconds]
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<FromGitter> <vladfaust> Which syntax is more grammatically correct? ⏎ ⏎ ```channel.await(Event) ⏎ channel.wait(Event)``` [https://gitter.im/crystal-lang/crystal?at=5ca99e8225686a7dc3ec0fdf]
<FromGitter> <bew> @vladfaust the "syntax" is exactly the same, the words are different though ^^ what is it for?
<FromGitter> <vladfaust> Well, it's for waiting for an event to happen. In a blocking way
<FromGitter> <bew> I'd say `wait` (i don't know what `await` means..)
<FromGitter> <vladfaust> async/await is a pattern (https://en.wikipedia.org/wiki/Async/await)
<FromGitter> <vladfaust> await is also an existing word https://www.merriam-webster.com/dictionary/await
<FromGitter> <vladfaust> "wait *for something*" and "await *something*"
<FromGitter> <bew> Actually it looks like `wait_for` & `await` would have the same meaning
<FromGitter> <vladfaust> I'm faster :p
<FromGitter> <vladfaust> So yes, *await* seems like a better fit
<FromGitter> <bew> Gitter (android) wasn't updating :p 👍
_whitelogger has joined #crystal-lang
DmitryBochkarev has joined #crystal-lang
ashirase has quit [Ping timeout: 250 seconds]
ashirase has joined #crystal-lang
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 250 seconds]
tsundsted has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
_whitelogger has joined #crystal-lang
<FromGitter> <vladfaust> I'd like to have a buffered channel with dynamic capacity. As seen at https://github.com/crystal-lang/crystal/blob/60760a5460aa13a1f80c5a1a7410782dc4076b77/src/channel.cr#L180, you could have just added the `capacity` property. But are there any hidden catches which would potentially crash the program?
<FromGitter> <vladfaust> Well, no. Accessing the `@deque` after `@capacity` changed raises
<FromGitter> <bew> What do you mean by "dynamic capacity"? "I could just add" you mean, adding it yourself to Channel? (I don't think that's a good idea..)
<FromGitter> <vladfaust> Yeah, that's what I want
<FromGitter> <bew> Hmm
<FromGitter> <vladfaust> Current fiber blocks when buffered channel is full
<FromGitter> <bew> Use a big buffer?
<FromGitter> <vladfaust> I want that channel to change size dynamically, so `full?` returns different result in different moments of time
<FromGitter> <vladfaust> I think `def size; @queue.size; end` would work for me now
<FromGitter> <vladfaust> No, it would not
<FromGitter> <vladfaust> I don't understand why queue raises after capacity changes...
<FromGitter> <vladfaust> https://carc.in/#/r/6oan
<FromGitter> <bew> @vladfaust I'd suggest creating your own Channel impl (with `< Channel(T)`) similar to `Channel::{Buffered Unbuffered}` and start playing from there
<FromGitter> <bew> This way you don't break existing code, and you can do your own things
<FromGitter> <vladfaust> That's not the attitude I'm used to
<FromGitter> <vladfaust> Should find the issue
<FromGitter> <vladfaust> So, I have to find a way to re-size deque
<FromGitter> <vladfaust> But thanks, creating a new Channel impl looks nice
<FromGitter> <vladfaust> That's so awesome that one could easily create their own Channel (!) implementation in Crystal
<FromGitter> <vladfaust> No, I still do not understand. If we change `@capacity` of a `Channel::Buffered`, then nothing should break, as `@queue << value` automatically increases the inner capacity (https://github.com/crystal-lang/crystal/blob/60760a5460aa13a1f80c5a1a7410782dc4076b77/src/deque.cr#L406)
<FromGitter> <vladfaust> Huh, it works nicely if `T` is `Bool` (i.e. not `Nil`)
<FromGitter> <vladfaust> Any clues?
<FromGitter> <vladfaust> https://carc.in/#/r/6oao
<FromGitter> <vladfaust> It also works with both classes and structs. The only thing that it crashes on is `Nil`
<FromGitter> <vladfaust> Is that a **BUG**?
<FromGitter> <vladfaust> #Bug?
<FromGitter> <michalvalasek> hello all! i'm a noob here and having problem running any crystal program. I'm on a mac (Mojave). When i run `crystal run src/my_app.cr`I get ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ca9ea6e759abc043c7f28f5]
<FromGitter> <michalvalasek> is there a way to fix this?
<FromGitter> <vladfaust> @michalvalasek you should have `libcrypto` installed on your machine
<FromGitter> <vladfaust> Which is kinda obvious from the message
<FromGitter> <vladfaust> Try something like `whatever-mac-apt-alternative install libcrypto-dev`
<FromGitter> <michalvalasek> that's of course what it tried first
<FromGitter> <michalvalasek> no luck tho, no such package on homebrew (`libcrypto` or `libcrypto-dev`)
<FromGitter> <vladfaust> Should either find a way to install that package, or symlink to an existing one
<FromGitter> <michalvalasek> yea, no such package in my `/usr/local/lib` either
DmitryBochkarev has quit [Ping timeout: 268 seconds]
<FromGitter> <michalvalasek> ok, thanks anyway
<FromGitter> <vladfaust> I did not help, I guess 😅
<FromGitter> <vladfaust> There are some mac users here, though
<FromGitter> <michalvalasek> btw. is there some REPL for crystal?
<FromGitter> <michalvalasek> i found `icr`, installed it via shards in my project, but dunno how to run it :)
<FromGitter> <michalvalasek> there doesn't seem to be an integrated first-party REPL directly in crystal
<FromGitter> <vladfaust> It's better to install it system-wide
<FromGitter> <vladfaust> And then just `$ icr`
<FromGitter> <michalvalasek> thanks! gonna try it
<FromGitter> <michalvalasek> i'm a total noob on a quest into crystal, appreciate your help
<FromGitter> <michalvalasek> i'm rewriting an old rails API into something more performant, so I thought crystal might work quite nice here
<FromGitter> <vladfaust> Indeed
<FromGitter> <vladfaust> IIRC it was asked before, but is there a fast way to `select` with priorities?
<FromGitter> <vladfaust> Just curious, I have plan B
<FromGitter> <vladfaust> You should always have plan B in Crystal :D
<FromGitter> <vladfaust> Am I right, @Blacksmoke16? :p
<tsundsted> @michalvalasek make sure you have openssl installed. you may need to install a version via homebrew
DmitryBochkarev has joined #crystal-lang
<tsundsted> it seems to be a common problem on mojave (i'm still running high sierra)
DmitryBochkarev has quit [Ping timeout: 250 seconds]
<FromGitter> <vladfaust> Well, the `when` defined earlier has higher precedence: https://carc.in/#/r/6ocb
tsundsted has quit [Ping timeout: 256 seconds]
_whitelogger has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> oh wow, the implementation of `forward_missing_to` has changed...
<FromGitter> <Blacksmoke16> @vladfaust indeed
DmitryBochkarev has joined #crystal-lang
DmitryBochkarev has quit [Remote host closed the connection]
DmitryBochkarev has joined #crystal-lang
DmitryBochkarev has quit [Max SendQ exceeded]
DmitryBochkarev has joined #crystal-lang
fanta7531 has joined #crystal-lang
DmitryBochkarev has quit [Ping timeout: 268 seconds]
DmitryBochkarev has joined #crystal-lang
DmitryBochkarev has quit [Ping timeout: 244 seconds]
DmitryBochkarev has joined #crystal-lang
<FromGitter> <ryanstout> Question if anyone knows. In the past I had seen a shard that had its own annotations. I'm working on a shard that lets you expose crystal code to ruby via ffi on the ruby side. Is there any docs for custom annotations? Or am I better off using macros?
<FromGitter> <ryanstout> (in this specific case, I want to mark a struct as something that gets generated using FFI::Struct on the ruby side also)
<FromGitter> <Blacksmoke16> ;D
<FromGitter> <Blacksmoke16> https://dev.to/blacksmoke16/utilizing-macros-annotations-in-a-web-framework-3abk plus those 2 shards i talk about might be a good place to start
<FromGitter> <Blacksmoke16> otherwise feel free to ask questions
<FromGitter> <Blacksmoke16> tl;dr
<FromGitter> <Blacksmoke16> `annotaiton MyAnnotation; end`
<FromGitter> <Blacksmoke16> then can use it
<FromGitter> <Blacksmoke16> ```@[MyAnnotation] ⏎ def foo ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5caa2707016a930a457c4d45]
<FromGitter> <dscottboggs_gitlab> *annotation but yeah
<FromGitter> <ryanstout> @Blacksmoke16 cool, thanks a bunch.
<FromGitter> <ryanstout> I'll check it out
<FromGitter> <Blacksmoke16> > (in this specific case, I want to mark a struct as something that gets generated using FFI::Struct on the ruby side also) ⏎ ⏎ this might be tricky as you'll face the same problem as https://github.com/crystal-lang/crystal/issues/7274
<FromGitter> <Blacksmoke16> er maybe not, i misread that
<FromGitter> <Blacksmoke16> np
<FromGitter> <ryanstout> yea, I think I could do something like: ⏎ ⏎ ```expose do ⏎ struct Something ⏎ .. ⏎ end ⏎ end``` ⏎ ⏎ (```expose``` is a placeholder, still thinking through the api) I could build the above with a macro that takes a block, but I was thinking annotations make for a better looking api I think. [https://gitter.im/crystal-lang/crystal?at=5caa282e93fb4a7dc2ed2eb4]
<FromGitter> <Blacksmoke16> whats the goal specifically? like what would you be doing within that block?
<FromGitter> <ryanstout> generating the FFI::Struct file on the ruby side, then returning the crystal struct AST back to the compiler
<FromGitter> <ryanstout> the idea is when you compile it would write out a file with all of the ruby ffi code needed to bridge.
<FromGitter> <bew> @dscottboggs_gitlab "forward_missing_to has changed" how so?
<FromGitter> <Blacksmoke16> so basic would want to get an array of all structs that have a given annotation, then do some logic and output a file?
<FromGitter> <ryanstout> @Blacksmoke16 (still early, might not work out in practice)
<FromGitter> <ryanstout> yea, exactly
<FromGitter> <Blacksmoke16> yea sadly you'll run into https://github.com/crystal-lang/crystal/issues/7274
<FromGitter> <ryanstout> yea, thats what I figured. Maybe better to stick to macros for now
<FromGitter> <Blacksmoke16> could do what i did for athena
<FromGitter> <Blacksmoke16> make a like `abstract struct FFI::Expose` then just have them inherit from that
<FromGitter> <Blacksmoke16> then can iterate over them via `{% for klass in FFI::Expose.subclasses %}`
<FromGitter> <ryanstout> yea, that could work. Just trying to figure out whats the best api for the end user.
<FromGitter> <Blacksmoke16> could still use the annotation to store metadata or something for that specific struct
<FromGitter> <Blacksmoke16> that you would have access to in that loop
<FromGitter> <Blacksmoke16> having #7274 would be great thats for sure
<DeBot> https://github.com/crystal-lang/crystal/issues/7274 (Add Annotation#types, #vars, #methods)
rohitpaulk has joined #crystal-lang
<FromGitter> <Blacksmoke16> actually give me a few hours, turns out its not that hard to add
<FromGitter> <Blacksmoke16> got types working
DmitryBochkarev has quit [Ping timeout: 268 seconds]
<FromGitter> <malkomalko> Is there anyway to force a return signature to be the abstract class if a method call happens to only return one of the types inheriting from the abstract class?
<FromGitter> <malkomalko> Looks like the compiler infers the explicit class instead of the base abstract class even if I explicitly mark the return signature as the base abstract class until the method I'm writing returns more than one of the classes inheriting from the abstract class. Gosh, that's a mouthful!
sagax has quit [Read error: No route to host]
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <malkomalko> nevermind, figured it out by casting with `.as(AbstractClass)`
<FromGitter> <Blacksmoke16> /cc @vladfaust @ryanstout
<FromGitter> <j8r> We can't build crystal apps statically with alpine@edge, libgc.a is missing - going to fix that
<FromGitter> <j8r> a mission for static-guy mps :P
<FromGitter> <straight-shoota> But for 0.28.0 it needs to be updated according to the changes in https://github.com/crystal-lang/distribution-scripts/pull/31
<FromGitter> <j8r> thanks, I submit a PR anyway the fix it `--enable-static` - that was easy :)
<FromGitter> <TheOnlyArtz> Is crystal really written in Crystal?
<FromGitter> <TheOnlyArtz> What about the lexer?
<FromGitter> <Blacksmoke16> crystal
<FromGitter> <j8r> yes, like C is written in C
<FromGitter> <j8r> (mostly).for clang/gcc
<FromGitter> <TheOnlyArtz> Yea I know, I'm trying to prove something
<FromGitter> <TheOnlyArtz> Thank you.
<FromGitter> <r00ster91> From the beginning Crystal was written in Ruby but now it's fully Crystal (besides some very little C and C++)
<FromGitter> <j8r> and ASM
<FromGitter> <tenebrousedge> lots of languages do similarly: https://en.wikipedia.org/wiki/Bootstrapping_(compilers)
<FromGitter> <j8r> I'm quite sure there is no C++
sagax has joined #crystal-lang
<wuehlmaus> find ./crystal -name '*.cc' only shows
<wuehlmaus> ./src/llvm/ext/llvm_ext.cc
fanta7531 has quit [Quit: fanta7531]
<FromGitter> <drum445> How do I convert a hexstring back to a string please?
<FromGitter> <r00ster91> With `to_i`: `"FA124".to_i(16)`
<FromGitter> <r00ster91> The base of hexadecimal is 16
<FromGitter> <r00ster91> Wait no you want it to a string
<FromGitter> <r00ster91> but what do you mean by "hexstring to string"?
<FromGitter> <drum445> Sorry, just used base64 now
<FromGitter> <drum445> think I was just using it wrong lol ;)
<FromGitter> <ryanstout> @Blacksmoke16 thanks, checking it out
<FromGitter> <Blacksmoke16> np, should allow for annotating a struct, then can iterate over each struct
hightower3 has joined #crystal-lang
<jokke> hey, how do i make an octet string out of a slice?
<jokke> .map(&.ord).join ?
<jokke> ah no
moei has quit [Read error: Connection reset by peer]
moei has joined #crystal-lang
hightower3 has quit [Ping timeout: 264 seconds]
Raimondi has joined #crystal-lang
moei has quit [Quit: Leaving...]
tsundsted has joined #crystal-lang