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
jemc has joined #crystal-lang
<FromGitter> <Blacksmoke16> @kinxer got a playground link?
<FromGitter> <Blacksmoke16> in your example there isnt really a way to get a class of `A` into `B` since there are no child classes and its abstract
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/5n26
<FromGitter> <Blacksmoke16> @proyb6 that doesnt work?
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/5n27
<FromGitter> <proyb6> @Blacksmoke16 Yup, your code work but I think I could use.includes? to first check if the string is exist before adding a gsub to the variable so that I can reduce unneeded gsub
<FromGitter> <Blacksmoke16> what are you trying to do?
<FromGitter> <proyb6> If it's possible to add chaining dynamically?
<FromGitter> <Blacksmoke16> maybe a macro?
<FromGitter> <Blacksmoke16> but not matter the solution it sounds like it wont be the most optimal thing
<FromGitter> <proyb6> To replace user input text and sanitize macilious code
<FromGitter> <proyb6> I see, maybe a string.build is optimize
<FromGitter> <Blacksmoke16> but how would you know what to build?
<FromGitter> <proyb6> Haven't try, have advice?
<FromGitter> <jeffmikels> Does anyone have experience using audio devices from crystal? I want to be able to send audio data directly to the audio device of a system.
<FromGitter> <Blacksmoke16> i do not sorry
<FromGitter> <Blacksmoke16> to both questions :p
<FromGitter> <Blacksmoke16> @proyb6 if you put together an example maybe?
Dreamer3_ has joined #crystal-lang
<FromGitter> <proyb6> Will try tonight, 20 hours time ;)
<FromGitter> <Blacksmoke16> kk
<FromGitter> <kinxer> @Blacksmoke16 https://play.crystal-lang.org/#/r/5n2d
<FromGitter> <kinxer> I'm doing some (intentionally) wonky stuff with `from_json` in the superclass (`A`, in this case), so I didn't include `JSON::Serializable`.
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <proyb6> @Blacksmoke16 https://gist.github.com/Nephos/ad292a3e2acc9201e6ea6342eb85dacb I got the inspiration from this gist
<FromGitter> <Blacksmoke16> maybe make an issue for it, seems crystal doesnt like abstract arrays of things
<FromGitter> <Blacksmoke16> https://github.com/crystal-lang/crystal/issues/6996 was issue i came across a while ago
Renich_ has joined #crystal-lang
Renich has quit [Ping timeout: 250 seconds]
Renich_ is now known as Renich
Renich has quit [Ping timeout: 268 seconds]
non-aristotelian has quit [Quit: non-aristotelian]
woodruffw has quit [Ping timeout: 246 seconds]
woodruffw has joined #crystal-lang
DTZUZO has quit [Ping timeout: 246 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <redcodefinal> Why do these two lines act differently? https://carc.in/#/r/5n38
rohitpaulk has quit [Ping timeout: 268 seconds]
DTZUZO has joined #crystal-lang
<FromGitter> <redcodefinal> This is what I'm trying to do but the `chr` method only casts to unicode, is there a way to force ascii?
<FromGitter> <redcodefinal> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bfe09eb958fc53895fe99b0]
Renich has joined #crystal-lang
<FromGitter> <redcodefinal> Maybe there is another way to go about this, is there a way to make a string from an `Array(UInt8)`?
Renich has quit [Ping timeout: 240 seconds]
Renich has joined #crystal-lang
akaiiro has quit [Ping timeout: 246 seconds]
akaiiro has joined #crystal-lang
Renich has quit [Ping timeout: 272 seconds]
<FromGitter> <dscottboggs_gitlab> @redcodefinal `String.new()` accepts an `Array(UInt8)` which it parses as UTF-8
<FromGitter> <redcodefinal> https://carc.in/#/r/5n48
<FromGitter> <redcodefinal> Am I using it wrong?
<FromGitter> <redcodefinal> Whats crazy too is that `"\x99"` is fine, and `"\x99".bytes.size` is 1. `'\x99'` throws an error, invalid escape sequence.
akaiiro has quit [Remote host closed the connection]
Renich has joined #crystal-lang
Renich has quit [Ping timeout: 250 seconds]
<FromGitter> <redcodefinal> I had to do this to make it work. I tried everything, macros, you name it. https://gist.github.com/redcodefinal/35003d3a8cab1deed87a4b0ad634ce4d
<FromGitter> <redcodefinal> That was the only solution I could find, I'm glad copy paste exists.
<FromGitter> <Blacksmoke16> you could make that with a macro :p
Dreamer3_ has quit [Quit: Computer has gone to sleep.]
<FromGitter> <Blacksmoke16> how would you go about having an initialize method and JSON::Serializable? https://play.crystal-lang.org/#/r/5n59
jemc has quit [Ping timeout: 250 seconds]
<FromGitter> <Blacksmoke16> with dynamic ivars...
<FromGitter> <redcodefinal> Oh duh I forgot that I had the change the method entirely after the fact. My original macro wasn't working because of the invalid escape sequence problem. I wanted to out a single char, not a string, but it wouldn't let me use `'\x99'`. Do you know why `"\x99"` is ok but `'\x99'` throws an error?
<FromGitter> <Blacksmoke16> `'` denotes a char type
<FromGitter> <Blacksmoke16> i.e. `'a'`
<FromGitter> <redcodefinal> @Blacksmoke16 your example won't work because you didnt set name in the initializer
<FromGitter> <redcodefinal> https://play.crystal-lang.org/#/r/5n59
<FromGitter> <redcodefinal> fixed https://play.crystal-lang.org/#/r/5n5a
<FromGitter> <Blacksmoke16> but say i would be inheriting the base class and dont know the ivars
<FromGitter> <Blacksmoke16> and seems you cant build out the initialize due to
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/5n5c
<FromGitter> <redcodefinal> @Blacksmoke16 I didn't notice that when I went through I was convinced something like '\x42' would work
<FromGitter> <Blacksmoke16> not the `\x`
<FromGitter> <Blacksmoke16> thats not a valid char escape
<FromGitter> <redcodefinal> @Blacksmoke16
<FromGitter> <redcodefinal> @Blacksmoke16 ⏎ Writing that macro and this is how far I got. I'm having trouble getting `char` to hexadecimal ⏎ https://carc.in/#/r/5n5l ⏎ This was one of the issues I was having when writing the macro for this. [https://gitter.im/crystal-lang/crystal?at=5bfe32aaf849b222e0b661f0]
<FromGitter> <redcodefinal> looked through all the `Crystal::Macro::ASTNode`docs and I didn't see a method I could use for converting a `NumberLiteral `to hex
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <Blacksmoke16> yea i dunno mate
<FromGitter> <redcodefinal> Yeah yours actually looks like it should work
<FromGitter> <redcodefinal> When I space out the lines in crystal play it specifically complains about the first {{
<FromGitter> <Blacksmoke16> oh i think i know
<FromGitter> <Blacksmoke16> https://carc.in/#/r/5n6a
<FromGitter> <redcodefinal> the output should be '[153_u8]'
<FromGitter> <redcodefinal> The problem is that "153_u8.chr" forces to unicode with no way to keep it to one byte.
<FromGitter> <Blacksmoke16> dunno about that one, least you got your macro working
<FromGitter> <redcodefinal> Thank you but it doesnt seem so https://carc.in/#/r/5n6o
<FromGitter> <Blacksmoke16> dunno bud, imma get to bed but hopefully someone else can figure it out
<FromGitter> <redcodefinal> gnight
devil_tux has joined #crystal-lang
<devil_tux> hi pps, your inputs for this issue would be greatly appreciated: https://github.com/crystal-lang/shards/issues/240
ashirase has quit [Ping timeout: 250 seconds]
ashirase has joined #crystal-lang
<FromGitter> <j8r> Does it exist a way to check if a variable has been initialized with a macro?
<FromGitter> <bew> Not that i know
<FromGitter> <bew> Why?
<FromGitter> <j8r> Because I've a recursive macro
<FromGitter> <j8r> a default value for the variable has to be set, but only once
<FromGitter> <bew> A local variable?
<FromGitter> <j8r> there is a macro, with local vars, which will call another macro, with its local vars etc.
<FromGitter> <bew> Maybe do one macro for the init and another macro for the recursive part
<FromGitter> <j8r> and the vars are passed as args
<FromGitter> <j8r> for now I do like this https://github.com/j8r/clicr/blob/master/src/clicr.cr#L31
<FromGitter> <bew> Or use fresh vars if you need separated local vars for each macro
<FromGitter> <j8r> a bit complicated to understand :)
<FromGitter> <j8r> no they have to be shared
<FromGitter> <bew> Wut that `1.times do...`
<FromGitter> <j8r> I can removed this i think
<FromGitter> <j8r> It was for isolation
<FromGitter> <j8r> inside the 1.times, the variables are scoped inside
<FromGitter> <j8r> but now I ve prefixed with `__` - all should be fine
<FromGitter> <bararchy> `1.times do` is my new hero
<FromGitter> <bararchy> :)
<FromGitter> <bew> There is no local scoping, so it's useless to me..
<FromGitter> <bew> Or what do you mean by scoping?
<FromGitter> <j8r> https://carc.in/#/r/5n7p
<FromGitter> <j8r> but since now I prefix all vars with `__`, they are considered as reserved - not needed anymore
<FromGitter> <bew> Ah indeed, forgot about that behavior, sorry
DeBot has joined #crystal-lang
<FromGitter> <rabingaire> Hello I want to contribute to Crystal project, The only experience I have on compiler design is that I have taken Compiler Design Course when I was on College, I have worked on ruby well enough to understand the crystal code but I am confused how to build the project for the development purpose can any of you guys help me get started.
Dreamer3_ has joined #crystal-lang
<FromGitter> <j8r> @rabingaire what OS you are, is Docker an option? See https://github.com/crystal-lang/crystal/wiki/All-required-libraries
<FromGitter> <rabingaire> Yep I can use docker
<FromGitter> <rabingaire> I am on Macos
<FromGitter> <rabingaire> Mojave
<FromGitter> <rabingaire> I have already done this step
<FromGitter> <j8r> or if you want to compile the language `https://github.com/crystal-lang/crystal; cd crystal; make`
<jhass> yeah, just make sure you got crystal installed through homebrew, clone the repo and run make
<FromGitter> <rabingaire> But before I run command make I need to install llvm right ??
<jhass> since it's self hosted you need to install a released version first
<jhass> ah yes, probably
<jhass> I think the homebrew formula has a --with-llvm switch? used to anyway
<jhass> also I think we're still depending on 6
<RX14> getting anything working on osx is a struggle
<FromGitter> <asterite> I actually think getting anything working on osx is easy :-)
<FromGitter> <rabingaire> `Makefile:59: *** Could not locate llvm-config, make sure it is installed and in your PATH, or set LLVM_CONFIG. Stop.`
<FromGitter> <rabingaire> actually the error I am getting is this !!!
<RX14> it's much easier to install crystal on linux than osx @asterite
<jhass> it's easy, maintaining is a struggle because the easyiness creates a mess
<RX14> osx is nice and user-friendly but it's toolchain is annoying
<FromGitter> <rabingaire> so I thought i need llvm on my computer
<RX14> @rabingaire you do
<jhass> brew install lvm@6
<jhass> eh llvm
<RX14> eh llvm@6
<jhass> and then link it explictly or something, brew will hin iirc
<FromGitter> <rabingaire> dang I installed llvm@5
<jhass> hint, gosh my typing today -.-
<RX14> llvm 5 works too
<RX14> brew link llvm@5 --force or something
<RX14> because homebrew doesn't install dependencies globally which is ???
<FromGitter> <rabingaire> `brew link llvm --force`
<FromGitter> <rabingaire> something like this
<RX14> llvm is probably llvm 7
<RX14> which isnt compatible with crystal
<RX14> llvm@5 or llvm@6 is what you need
<jhass> what's missing there again btw?
<RX14> it just segfaults
<RX14> lol
<RX14> well, it trips an assertion
<RX14> in the IRBuilder iirc
<RX14> and i gave up
<FromGitter> <rabingaire> you guys are great, I was afraid of asking questions at first
<RX14> jhass, llvm7 needs some weird fiddling around with the code to get intrinsics to work but i fixed that
<RX14> but the assertion failure i couldn't understand
<FromGitter> <asterite> RX14: it's just `brew install crystal` :-)
<RX14> @asterite yeah but then you need to do a bunch of fiddling to work on crystal itself
<RX14> a bunch of arcane xcode and brew commands which make little sense
<jhass> the problem is that homebrew is not apples child so it has to fight against apples way of doing things
<RX14> linux you just run `make`
<RX14> and it's already working
<RX14> jhass, exactly
<RX14> ok, on archlinux you just run `make`
<RX14> debian is a little different
<jhass> and apple not providing anything remotely being a replacement of course
<RX14> apple is a great developer OS*
<RX14> *for interpreted languages
<jhass> idk, I always forget to homebrew upgrade for weeks and then all the little tools updating and nagging on their own but some... it's a mess
<RX14> btw i use arch :)
<jhass> some stuff even is in the old windows days of oh btw there's a new version click here to go to the website and do all the same stuff you did to get me in the first place
<FromGitter> <rabingaire> Don't know about language design but for general programming osx is great but still it's only my opinion
<RX14> yeah, on balance it's probably better than linux for most devs
<RX14> but it'd annoy me too much
<FromGitter> <f1refly_gitlab> In my experience apple os is for devs who don't really care about computers
<FromGitter> <rabingaire> Hipster Developer = osx LOL
<FromGitter> <f1refly_gitlab> The type of guys who do it 100% for the money and get annoyed when people discuss about what editor they like the most
<FromGitter> <j8r> Alpine is also good, APKBUILDs are easy to make, static linking work
<RX14> yeah, alpine is nice but i'm not sure i'd use it as a desktop OS
<FromGitter> <j8r> what's remaining is a ready-to-use pre condifured Desktop GUI
<FromGitter> <drum445> @RX14 you love windows though right? ;)
<RX14> nope
<RX14> i hate it
<RX14> it's terrible
<FromGitter> <drum445> Amen
<FromGitter> <f1refly_gitlab> Man, we should've grabbed a coffe together when i was in bristol last year
<RX14> :)
<FromGitter> <j8r> @RX14 there is https://pkgs.alpinelinux.org/packages?name=*gnome*&branch=edge , theoretically it won't be much different than Arch UI wise
<RX14> i'm not really the distro-hopping type
<RX14> i have my arch setup and it works and i'm probably not going to ever change it
<RX14> until i finally snap and make my own distro lmao
<FromGitter> <drum445> You an i3 guy?
<RX14> yep
<FromGitter> <rabingaire> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bfea0e8958fc538950252b1]
<FromGitter> <rabingaire> I got this after I ran make
<FromGitter> <drum445> Fair, XFCE for me
<FromGitter> <rabingaire> what's happening here ??
<FromGitter> <j8r> Me not too, this is why I want to have the more minimal, easy to use, distro possible. BSDs and Alpine fits this, but for now quite limited for Desktop use - packages and configurations are missing
<FromGitter> <bew> @rabingaire well it's compiling, let it finish!
<jhass> rabingaire: it's building
<FromGitter> <rabingaire> it stoped after spitting those logs
<RX14> yeah it takes a minute or two
<FromGitter> <f1refly_gitlab> How can one even do anything with a tiling wm? i tried it for a week and almost went insane
<FromGitter> <rabingaire> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bfea1b6f59704348e19b409]
<FromGitter> <f1refly_gitlab> Building crystal takes quite a bit of efford :)
<FromGitter> <rabingaire> Do I have to change something hre ??
<FromGitter> <rabingaire> *here
<RX14> @rabingaire it takes a minute or two, just leave it
<RX14> if you want progress just set progress=t
<RX14> make crystal progress=t
<FromGitter> <rabingaire> oh !! my bad it's running on background
<FromGitter> <bew> @f1refly_gitlab tiling wm are nice, but not easy to get into for some people, it depends how you work/organize-everything too
<RX14> @f1refly_gitlab tiling WMs have a high learning curve but i enjoy my setup
<RX14> I don't even use the keyboard shortcuts that much
<FromGitter> <f1refly_gitlab> Where did you people start?
<RX14> with a lot of free time
<FromGitter> <f1refly_gitlab> I live in vim so learning shortcuts isn't an issue :)
<RX14> i started by just using it tbh
<FromGitter> <f1refly_gitlab> Well thats a shame, one of the things i don't have quite enough of
<RX14> the only reason I use tiling WMs is not to tile stuff
<FromGitter> <bew> Lool
<RX14> it's just that i maximise every window on windows anyway
<RX14> so why bother when you can have i3 do it for you :P
<RX14> i very rarely use anything else but tabbed workspaces in i3
<RX14> my workflow is tabs inside workspaces
<RX14> and i use mouse + scrollwheel to change between workspaces and tabs
<FromGitter> <f1refly_gitlab> but what about floating windows like authentification dialogs? herbstluft broke those to unusability
<FromGitter> <bew> Ah yes, i usually h1ve 1, maximum 2 window per workspace (but can have a lot them)
<RX14> i3 handles them fine
<RX14> they just float normally
<FromGitter> <f1refly_gitlab> Hmm
<FromGitter> <f1refly_gitlab> Ill try that again then i guess
<RX14> i3 is the easiest to use tiling WM
<RX14> with good defaults
<FromGitter> <bew> If you like Lua and insange config, there is AwesomeWM :p
<RX14> so i'd recommend people start there
<FromGitter> <bew> That's true
<FromGitter> <bew> There's bspwm which is nice too
<FromGitter> <f1refly_gitlab> I used awesome a few years ago but cinnamon did all the things i tried to script so i just changed to that eventually ^^
<FromGitter> <f1refly_gitlab> Hmm
<FromGitter> <f1refly_gitlab> I'll experiment with window managers during christmas vacation
<FromGitter> <f1refly_gitlab> thank you guys
<RX14> np
<RX14> i3's very well documented too
<RX14> so thats another thing
<FromGitter> <bew> And there's a crystal shard to control it
<RX14> lol
<FromGitter> <bew> I saw that one some weeks ago
<FromGitter> <f1refly_gitlab> Hehe
<FromGitter> <f1refly_gitlab> Thats great
<RX14> i need to replace my statusline with something crystal-based
<RX14> i currently use i3blocks and im certain it's eating my battery by spawning 20 bash scripts a second
<FromGitter> <f1refly_gitlab> That could be a problem, yes
<FromGitter> <bew> I have a cool lemonbar based module system written in Crystal, but never finished handling moude events ><
<FromGitter> <f1refly_gitlab> But then again those are probably 10 lines each
<FromGitter> <f1refly_gitlab> Do you have a link?
<FromGitter> <f1refly_gitlab> @bew
<FromGitter> <bew> It's a private repo for now, but if you're interested i can open it
<jokke> bew: cool :)
<FromGitter> <bew> here we go https://github.com/bew/lemonade :D
<FromGitter> <bew> I've written some ideas about what I'd like the lemonade framework to be, if you agree or have comments/other idea, feel free to open issues
<FromGitter> <f1refly_gitlab> I'll check it out when i have some time :)
<FromGitter> <bew> np :)
<FromGitter> <rabingaire> I got two files `crystal` and `crystal.dwarf`
<FromGitter> <rabingaire> is this what I was supposed to get ??
<RX14> I'm probably going to end up making my own bar because its too small and too fun of a task not to nih
<FromGitter> <bew> Totally true, please tell me when you have something somewhat usable :)
<RX14> i'll make sure to tell you in 2020
<FromGitter> <f1refly_gitlab> @rabingaire `crystal` is probably the compiler, run it to make sure
<FromGitter> <bew> @rabingaire yes it's normal
<FromGitter> <bew> crystal is the compiler, the other is debug info
<FromGitter> <bew> (for when the compiler crashes iirc)
<FromGitter> <bew> Whenever you're ready rx14 👍
<livcd> RX14: interesting I was also looking into making a bar / simple bspwm thing recently
<FromGitter> <rabingaire> Yep I am getting -dev version
<RX14> @rabingaire once you compile the compiler with `make crystal` it's in .build/crystal
<RX14> and then you can use bin/crystal
<RX14> which uses the compiled compiler with the stdlib in the git repo
<FromGitter> <f1refly_gitlab> or better copy `crystal` to somewhere in your PATH
<RX14> no, that's worse
<RX14> far worse
<RX14> if you do that it probably wont be able to find the stdlib
<RX14> and other stuff
<RX14> thats why we have the bin/crystal wrapper script
<RX14> plus you dont want development crystal to be your main crystal
<FromGitter> <f1refly_gitlab> Unless you want exactly that :D
<RX14> then add /path/to/repo/bin to PATH
<FromGitter> <giuseongit> Hi folks, I'd like to run crystal on my raspberry pi, apt tells me it cannot find `crystal` package for `armhf` arch. I did a quick search and the last thread talking about it dates back to at least one year ago. Is it possibile to install crystal on the rbpi without having to cross-compile the compiler from x86 to arm?
<RX14> copying .build/crystal or bin/crystal to somewhere else will break the install @f1refly_gitlab
<RX14> @giuseongit you have to cross-compile or use something someone else has cross-compiled
<FromGitter> <rabingaire> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bfeabfef048fa1051384fa7]
<FromGitter> <rabingaire> this is what I wanted to do
<RX14> there is http://public.portalier.com/raspbian/ @giuseongit
<RX14> but it's out of date
<FromGitter> <f1refly_gitlab> To be honest i've never tried compiling the compiler manually
<FromGitter> <giuseongit> yeah, I've already tried it, but it gives me the same error
<RX14> weird
<FromGitter> <giuseongit> I mean, apt tells me that it cannot find the armhf package
<FromGitter> <rabingaire> I wanted to check what value is passed as a parameter on a method written inside compiler parser
<FromGitter> <rabingaire> what I did is I changed code in compiler source code
<FromGitter> <rabingaire> build it
<FromGitter> <rabingaire> and ran playground using dev compiler
<FromGitter> <rabingaire> whenever I run the program it spits out this on my terminal
<FromGitter> <rabingaire> I think this is how you guys do thing or am I doing something wrong ??
DTZUZO has quit [Ping timeout: 240 seconds]
<FromGitter> <bew> do you have an example of the check you want to do? or what modifications you did?
<FromGitter> <rabingaire> i just added `puts "to_lhs is printing this ---------> #{exp}"`
<FromGitter> <rabingaire> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bfead24ced7003fe19c94d8]
<FromGitter> <rabingaire> this is the method I am looking at
<RX14> @giuseongit perhaps the files got deleted :(
<FromGitter> <rabingaire> it's inside `src/compiler/crystal/syntax/parser.cr`
<RX14> if I had time i'd get crystal's CI and stuff sorted but...
<FromGitter> <rabingaire> I just wanted to see what's being passed at this method as a params
<FromGitter> <giuseongit> I'll try in the next week if I can find something, otherwise I'll have to compile the compiler. I just wanted to write a low-level interface for the GPIO, it could open an entire new market for crystal itself
<RX14> @giuseongit I wrote a tutorial on cross-compiling on stackoverflow
<FromGitter> <bew> @giuseongit true! I'd be interested if you manage to get sth working wrt gpio :)
<RX14> i'm sure you've seen it
<FromGitter> <giuseongit> @bew I'd like to have a working crystal compiler on arm to avoid any issues a kickstart the interface development
<FromGitter> <giuseongit> it isn't difficult, after all, you only have so handle a bunch of file descriptors
<FromGitter> <giuseongit> but considering that the largest market share for iot development goes to python (which can be slow/resource-consuming on arm) I felt that crystal would be a nice, light-weight, high level programming language to use
Renich has joined #crystal-lang
<FromGitter> <giuseongit> still, I don't have much time as I'm working on it in my spare time
<FromGitter> <Aaron-Fleisher> Really been enjoying Crystal lately. Works very well for the game server. The doc pages are very nice as well, love the inline examples they show!
<FromGitter> <bew> @giuseongit I second that ;)
<FromGitter> <kinxer> Is this expected behavior: https://play.crystal-lang.org/#/r/5n8z ? I'm trying to `include JSON::Serializable` in an intermediary superclass but then serialize a collection of the highest-level superclass. I can fix it by moving the `include JSON::Serializable` to `Specific` (https://play.crystal-lang.org/#/r/5n90), but I'm wondering if this difference is intentional.
<FromGitter> <drujensen> @kinxer not sure bit is this what you are looking for? https://play.crystal-lang.org/#/r/5n97
<FromGitter> <kinxer> @drujensen Yeah, that'll work. Thank you.
<FromGitter> <drujensen> 👍
<FromGitter> <drujensen> there might be a better way of doing that. I personally think the macro is a little hacky
non-aristotelian has joined #crystal-lang
<FromGitter> <rabingaire> Hey Guys Do I have to recompile when I change code on the source file of the compiler
<jokke> yes
<FromGitter> <rabingaire> for example if I have kept puts on some method and want to check what value is passed
<jokke> what?
<FromGitter> <rabingaire> I need to recompile it and throw a simple program and see logs
<jokke> i have no idea what you mean, sorry :/
<FromGitter> <rabingaire> Haha My bad
<jokke> if you change anything in crystal/compiler you will obviously have to rebuild crystal and only after that your changes will be visible the next time you compile something
<FromGitter> <rabingaire> exactly i was asking if there is some sort od automation
<FromGitter> <Blacksmoke16> be sure to reference the compiled crystal binary not the one installed on sys
<FromGitter> <rabingaire> *of
<FromGitter> <Blacksmoke16> `./bin/crystal`
<FromGitter> <rabingaire> Ok got it guys I was looking if there is automation or something
<FromGitter> <rabingaire> It kind of hard to recompile time and again on simple changes on the code
<FromGitter> <rabingaire> but it's a compiler not some sort of javascript framework haha
<RX14> @rabingaire you can use something like http://entrproject.org/ to run make crystal for you
blassin has quit [Ping timeout: 264 seconds]
<FromGitter> <kinxer> Is it recommended to avoid using `JSON::Any`?
blassin has joined #crystal-lang
<FromGitter> <rabingaire> Thanks @RX14
<FromGitter> <rabingaire> I will try it
<FromGitter> <j8r> @kinxer if you want perf and nice Object abstractions, yes
<FromGitter> <j8r> Any will parse the whole document
DTZUZO has joined #crystal-lang
<FromGitter> <kinxer> @j8r Gotcha. I'm working on a library for working with geoJSON in an OO manner, and I'm currently trying to figure out how to de-serialize a JSON array of geometry objects (which is an abstract class/category) into their specific types of geometries.
<FromGitter> <sdogruyol> @j8r have you ever got any stacktrace on alpine?
<FromGitter> <j8r> @sdogruyol when compiling statically? nope
<FromGitter> <sdogruyol> yeah, I just used your dockerfile for static compilation
<FromGitter> <sdogruyol> it works until it's broken :P
<FromGitter> <sdogruyol> thanks a lot for the doc
<FromGitter> <j8r> yes I wouldn't be surprised that's its broken now
<FromGitter> <j8r> because of openssl-libressl change
<FromGitter> <sdogruyol> nope, it works 👍
<FromGitter> <j8r> good news then :)
<FromGitter> <j8r> related discussion: https://github.com/crystal-lang/crystal/pull/6945
Renich has quit [Ping timeout: 250 seconds]
akaiiro has joined #crystal-lang
Renich has joined #crystal-lang
rohitpaulk has joined #crystal-lang
Renich_ has joined #crystal-lang
Renich has quit [Ping timeout: 245 seconds]
Renich_ is now known as Renich
rohitpaulk has quit [Ping timeout: 246 seconds]
ua has quit [Ping timeout: 250 seconds]
ua has joined #crystal-lang
Renich has quit [Remote host closed the connection]
Renich has joined #crystal-lang
<FromGitter> <greenbigfrog> ```code paste, see link``` ⏎ ⏎ Is there a nicer way of waiting for availabilty here? [https://gitter.im/crystal-lang/crystal?at=5bff02a7a115c91ef7aa63bd]
<FromGitter> <kinxer> Is `BitcoinRpc` your own class?
<FromGitter> <greenbigfrog> yeah
<FromGitter> <kinxer> Is it an `IO`?
<FromGitter> <greenbigfrog> (I do not want BitcoinRpc to have its own wait for availabilty function)
<FromGitter> <kinxer> Oh, okay.
<FromGitter> <kinxer> Given that you're using exceptions as part of your logic, I think you're going to have to go with `begin...rescue`. However, you can replace `rpc.nil?` with `!rpc`.
sz0 has joined #crystal-lang
<FromGitter> <kinxer> Also, your `method_missing` macro usage that turns the method call into an HTTP POST is interesting but makes it a little difficult to read at first.
<FromGitter> <greenbigfrog> TBH I had no idea how that shard actually worked in detail the first time I used to it :)
<FromGitter> <dscottboggs_gitlab> shouldn't this https://carc.in/#/r/5ndg output ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5bff08adf048fa10513af775]
<FromGitter> <dscottboggs_gitlab> shouldn't this https://carc.in/#/r/5ndg output ⏎ ⏎ ```idx # => 4 ⏎ idx # => 3 ⏎ idx # => 2 ⏎ idx # => 1``` [https://gitter.im/crystal-lang/crystal?at=5bff08e57d26db1e830f3eb0]
<oprypin> dscottboggs_gitlab, no
<FromGitter> <kinxer> @greenbigfrog How about this? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bff0a177074b903686eb047]
<FromGitter> <dscottboggs_gitlab> ok
<oprypin> just do avoid some confusion, same example https://carc.in/#/r/5ndm
<oprypin> *to
<FromGitter> <dscottboggs_gitlab> right, duh.
<FromGitter> <dscottboggs_gitlab> but each example should still output four times?
<oprypin> no. you're starting from the last item and going forward from there
<FromGitter> <dscottboggs_gitlab> https://crystal-lang.org/api/0.27.0/Indexable.html#each_index%28%2A%2Cstart%3AInt%2Ccount%3AInt%2C%26block%29-instance-method ⏎ ⏎ > Negative indices count backward from the end of the array. (-1 is the last element).
<oprypin> waaait a second , yeah I just reached that point
<FromGitter> <dscottboggs_gitlab> I got a working version https://carc.in/#/r/5ndp but I think I should file a bug for that other sample
<oprypin> dscottboggs_gitlab, well it's just confusingly worded. nothing actually counts backward, it just sets the starting point differently
<FromGitter> <dscottboggs_gitlab> OHHH
<oprypin> if there was some mistake there, the example would have been wrong, but it's correct
<FromGitter> <dscottboggs_gitlab> I see
<FromGitter> <greenbigfrog> How would I go about getting the output of `Process.run` in a string?
<FromGitter> <dscottboggs_gitlab> in your case can you use the backtick-method?
<FromGitter> <dscottboggs_gitlab> https://crystal-lang.org/api/0.27.0/toplevel.html#%60%28command%29%3AString-class-method
<FromGitter> <j8r> note the backtick spawn a shell running the command
<FromGitter> <dscottboggs_gitlab> yes that can be slow depending on your default shell
<FromGitter> <j8r> I you don't need a shell interpreter, better to use Process directly
<oprypin> no, don't use the backtick, it's just an ugly shortcut for an existing mechanism
<FromGitter> <greenbigfrog> thanks @kinxer
<FromGitter> <kinxer> @greenbigfrog It's not really much of an improvement, but it arguably looks a little cleaner and is one line shorter. You're welcome, though.
<FromGitter> <greenbigfrog> Yep 😄
<FromGitter> <j8r> what's the diff between `Process::Redirect::Pipe` and `IO::Memory`
<FromGitter> <greenbigfrog> What are you trying to say @oprypin
<oprypin> greenbigfrog, i linked you to a code example how to get output :D
<FromGitter> <j8r> lol
<oprypin> BUT don't use `shell: true`
<FromGitter> <greenbigfrog> ah. now I see :)
<FromGitter> <j8r> @oprypin do you know any advantage of `Process::Redirect::Pipe` vs `IO::Memory`?
<oprypin> no
<oprypin> i'm actually thinking really hard about this - why even provide an IO overload if getting the output is this easy
<FromGitter> <greenbigfrog> If I remove `shell: true`, I get `Unhandled exception: execvp: No such file or directory: No such file or directory (Errno)`
<FromGitter> <j8r> for example redirect to a socket? But yeah for IO::Memory it's useless
<FromGitter> <dscottboggs_gitlab> without shell=true you need the acutal file you're executing
<FromGitter> <dscottboggs_gitlab> then the arguments need to be in a list form
<FromGitter> <j8r> @greenbigfrog you are using file globing?
<FromGitter> <dscottboggs_gitlab> so ⏎ ⏎ ```Process.run "echo", args: ["hello", "world"]``` ⏎ ⏎ roughly [https://gitter.im/crystal-lang/crystal?at=5bff0e57cb32736b29ab5769]
* FromGitter * greenbigfrog is confused
<FromGitter> <dscottboggs_gitlab> hang on green big frog I'm gonna make a killer method for you
<oprypin> i guess the module does need documentation
<FromGitter> <dscottboggs_gitlab> https://carc.in/#/r/5ne2
<oprypin> oh no
<FromGitter> <dscottboggs_gitlab> oh shit you're right that's so bad
<FromGitter> <dscottboggs_gitlab> NEVERMIND! haha
<FromGitter> <greenbigfrog> ?
<FromGitter> <dscottboggs_gitlab> if you have spaces in a single argument that breaks things badly
<FromGitter> <dscottboggs_gitlab> the method I wrote pays no mind to quoted strings
<FromGitter> <j8r> @dscottboggs_gitlab this reminds me https://github.com/j8r/exec.cr#examples
<FromGitter> <j8r> I think I''ll refactor the shard to replace IO::Memory
<oprypin> j8r, i don't think that would be an overall improvement
<FromGitter> <dscottboggs_gitlab> does that pay mind to quoted strings when it uses the shell-like syntax?
<oprypin> no
<FromGitter> <j8r> Maybe I'll only keep the parsing thing, and return a `Process`
<oprypin> returning a wrapper with both output and status is a good thing
<oprypin> j8r, actually yeah that would be an improvement
<oprypin> j8r, but the biggest gap in your lib is that there is no way to *not* consume output. what if I want to just print it out some of the time? well, actually, now that I think about it, that would be Process.run :D
<oprypin> anyhow, the dream API is here, if anyone wants inspiration https://docs.python.org/3/library/subprocess.html#subprocess.run
<FromGitter> <dscottboggs_gitlab> oprypin I don't see that much of a difference between `Process.run` and `subprocess.run` or between `Process.exec` and `subprocess.Popen`
<FromGitter> <dscottboggs_gitlab> when I'm writing python I usually use Popen these days because why not have concurrency
<oprypin> the big difference is the return value https://docs.python.org/3/library/subprocess.html#subprocess.CompletedProcess
<oprypin> and it's kinda what @j8r was going for
<oprypin> like^
<FromGitter> <j8r> directly having the stderr, stdout available as strings?
<oprypin> yes but only if you opt into that
<oprypin> if anyone is still looking for an example,
<oprypin> `proc = Process.new("echo", ["hello", "world"], output: Process::Redirect::Pipe); p! proc.output.gets_to_end` @greenbigfrog
<oprypin> crystal also really needs https://docs.python.org/library/shlex.html but i don't think there is any shard for that. this would fix all those `split(" ")` dangers
<FromGitter> <dscottboggs_gitlab> ooh that's cool
<FromGitter> <j8r> a minimal cut-off shell parser
<FromGitter> <j8r> my shard is an even more basic lexical analyser
<oprypin> technically true
akaiiro has quit [Ping timeout: 268 seconds]
<FromGitter> <kinxer> I've seen discussion of the Crystal standard library avoiding methods with multiple aliases (e.g. `String#size` AND `String#length`); is this recommended style for community shards as well or just a goal for the standard library?
<FromGitter> <dscottboggs_gitlab> I believe one of the goals of crystal is to avoid unnecessary aliases in general, yes
<oprypin> kinxer, i have not seen any deviations between crystal's own style and the generally recommended style
Renich has quit [Ping timeout: 240 seconds]
akaiiro has joined #crystal-lang
akaiiro has quit [Ping timeout: 250 seconds]
akaiiro has joined #crystal-lang
Renich has joined #crystal-lang
shmibs has quit [Quit: leaving =o]
shmibs has joined #crystal-lang
shmibs has quit [Client Quit]