ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.21.1 | Fund Crystal's development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
fenicks has left #crystal-lang [#crystal-lang]
<FromGitter> <bew> nvm, I broke the rule do-it-without-macros-first...
<kodo[m]> Can you do a `eval` in crystal?
<FromGitter> <bew> no
<kodo[m]> I guess that would be a macro
<FromGitter> <bew> a eval is usually a runtime code evaluation/execution
<FromGitter> <bew> macros are compile-time
<kodo[m]> ah
<kodo[m]> is there anything similar?
<FromGitter> <bew> nop
<FromGitter> <bew> what do you want to do ?
<kodo[m]> i was thinking of allowing bot to run some crystal code
<FromGitter> <bew> you'll need to compile first then run
<kodo[m]> Ha
Renich__ has joined #crystal-lang
<kodo[m]> that's kinda what I was looking for
<kodo[m]> although I guess that only works at compile time. I can't read that as data like you said
<FromGitter> <bew> yes
Renich__ is now known as Renich
<Renich> Guys, I have a config file in yaml. I want to be able to access it's values as config.credentials.service.key, for example.
<Renich> How would you do it?
<Renich> Also, I am interested in bootstraping properly. If anyone can offer any pointers, it would be good. Basically, I need t o initializa logging and read the config file.
<FromGitter> <bew> Renich you should look at: https://crystal-lang.org/api/0.21.1/YAML.html#mapping-macro
<Renich> FromGitter: bew: Thanks, I will
<FromGitter> Renich, I'm a bot, *bleep, bloop*. I relay messages between here and https://gitter.im/crystal-lang/crystal
<FromGitter> <bew> https://crystal-lang.org/api/0.21.1/YAML.html#mapping(properties,strict=false)-macro
<kodo[m]> oh I forgot yaml had native mapping
<kodo[m]> I might have to use it, i'm more of a toml guy myself though
<Renich> bew: interesting. But it doesn't have a multi-level example. What if the yaml file is something like:
<Renich> department -> user -> name
<Renich> or credentials -> service -> key
<FromGitter> <bew> look at the example for `JSON.mapping` here: https://crystal-lang.org/api/0.21.1/JSON.html#mapping(properties,strict=false)-macro it should work the same for YAML
<Renich> bew: thanks
<FromGitter> <bew> it works ?
snsei has quit [Remote host closed the connection]
balduin has joined #crystal-lang
<Renich> bew: well, still trying to figure out bootstrapping actually
bew78 has joined #crystal-lang
<bew78> domgetter: are you there ?
greengriminal has joined #crystal-lang
<FromGitter> <bew> domgetter: just made it work!!! https://gist.github.com/bew/9371c08d1389922bc4a8f91d5f29523f
<FromGitter> <bew> I think it could be interesting to have this `LazyIterator` in the stdlib (maybe under another name)
bew78 has quit [Quit: WeeChat 1.7]
<FromGitter> <elorest> I figured out my issue with sockets and fibers. Apparently within the fiber it was referring to the same socket so when I closed it it closed all of them. I fixed it by passing it into a proc. https://gist.github.com/elorest/95256e5cb450e3b25ccf28a2fc5707e4
<FromGitter> <bew> server.cr#L7 should be `name = sock.gets`
<FromGitter> <elorest> excellent point. I'm surprised it worked.
<FromGitter> <bew> I don't think you 'need' a Proc here
<FromGitter> <bew> try without, maybe there was a typo that you fixed by trying with a Pro
<FromGitter> <bew> Proc
<FromGitter> <elorest> the reason i think I do is that if I close it for one fiber it closes it for all fibers and all of my other clients to error. Look at screen shots above. I would love to do it without a proc though if possible.
<FromGitter> <bew> yes, for a given client, if you close the socket somewhere, it'll be unavailable in the other fibers which has a reference to this specific clint
<FromGitter> <bew> client*
<kodo[m]> Anyone know a qr code lib? Don't see one on awesome crystal
<FromGitter> <elorest> @bew What I did was started the server then ran the client in 2 different terminal windows. After entering my name in one, the other one caused the server to throw a Closed Stream IO::Error
<FromGitter> <bew> kodo[m]: does not seems to exist yet (no shards on http://crystalshards.xyz/?filter=qr)
<FromGitter> <elorest> @bew if possible i would love to do it without procs but I just removed it and now it errors if I have more than one call to it at once.
<FromGitter> <bew> @elorest `sock.close`, closes only `sock` not all opened sockets, can you share the code?.. you can know if a socket is closed or not with `sock.closed?`
<FromGitter> <elorest> I've revised the gist above with procs commented out. I'm just starting one server and then 2 clients before entering the name to either of them. Entering it on one breaks the other.
<FromGitter> <bew> you haven't commented the `end` of the proc
<FromGitter> <elorest> I was hoping you looked after I fixed that lol. That's not the error I meant though.
<FromGitter> <bew> I know ^^
<FromGitter> <elorest> here's the error I get on the second client ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58d87931b52518ed4dae1c8d]
<FromGitter> <elorest> @bew thanks for your help. sorry for the typo.
<FromGitter> <bew> weird, it crashed the first time I tried, now it does not want to crash :(
<FromGitter> <elorest> weird. I can't make it not crash without the proc. In the docs under spawning a call it says that ⏎ ⏎ ```https://crystal-lang.org/docs/guides/concurrency.html``` [https://gitter.im/crystal-lang/crystal?at=58d87d4a4cb8d091732d3e39]
<FromGitter> <elorest> Not sure if a socket is different somehow due to not being an Int32...
<FromGitter> <bew> ok I got it to crash
<FromGitter> <bew> every time
<FromGitter> <bew> I think you're right
<FromGitter> <bew> @elorest
<FromGitter> <elorest> @bew. Dang it I hate being right. I guess using a proc isn't that bad though.
<FromGitter> <bew> hate being right ? why ? the proc is good then, yes
<FromGitter> <elorest> @bew it just would have made for a bit simpler code if you were right in this case. Yeah it's fine though. Thanks for your help.
<kodo[m]> How do I get least significant bit of a byte?
<kodo[m]> ah looks like .bit
<kodo[m]> how do I 30644080 * 30644080 without overflowing?
<kodo[m]> ah to_u64
carbonage has quit [Quit: Leaving]
greengriminal has quit [Quit: This computer has gone to sleep]
<domgetter> bew: awesome! I'll go play with the LazyIterator a little bit
<FromGitter> <bew> domgetter: see #4198 I posted a better version of it :)
<DeBot> https://github.com/crystal-lang/crystal/issues/4198 (An Iterator on big dataset (lazy generated))
greengriminal has joined #crystal-lang
<kodo[m]> TIL if you don't map all the fields of a c struct stack gets corrupted
balduin has quit [Ping timeout: 240 seconds]
greengriminal has quit [Quit: Leaving]
sz0 has quit [Quit: Connection closed for inactivity]
Qchmqs has joined #crystal-lang
mark_66 has joined #crystal-lang
Kug3lis has joined #crystal-lang
bjz has joined #crystal-lang
<snapcase> can I stream parse large JSON documents with crystal?
<kodo[m]> How do i make a strruct out of a struct pointer?
<kodo[m]> from c lib
<kodo[m]> oh #value hrm
<kodo[m]> how does it know how big the address space is?
* kodo[m] doesn't know low level stuff very well
Kug3lis_ has joined #crystal-lang
Kug3lis has quit [Ping timeout: 258 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
danielpclark has quit [Remote host closed the connection]
gloscombe has joined #crystal-lang
<domgetter> Is there somewhere I can read up more on macro methods?
<domgetter> I'm trying to interact with a block that is passed to a macro, but I can't figure out what methods I can even call on it.
<domgetter> It's just telling me "undefined macro method 'Block#call'"
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 240 seconds]
unshadow has joined #crystal-lang
gloscomb1 has joined #crystal-lang
gloscombe has quit [Ping timeout: 240 seconds]
mark_66 has quit [Read error: Connection reset by peer]
mark_66 has joined #crystal-lang
<kodo[m]> Hrm I got a struct pointer that I'm calling #value on but it seems to be failing. is there a way to check for errors?
<kodo[m]> Oh that's weird. the struct is returning ok just one of the values is 1 when it should be greater...
akwiatkowski has joined #crystal-lang
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
skinkitten has joined #crystal-lang
<crystal-gh> [crystal] bcardiff pushed 1 new commit to master: https://git.io/vStnk
<crystal-gh> crystal/master 3c74890 Will Leinweber: Fix TCPSocket segfault on missing host and 0 port (#4177)...
<unshadow> this kinda sucks
<FromGitter> <sdogruyol> not sure why kemal performs so low
<RX14> it gets 0 lol
<FromGitter> <fridgerator> 1,403 errors
<RX14> the things are just failing
<unshadow> Can we contact them ?
<FromGitter> <sdogruyol> check other tests
<unshadow> maybe it's just not confuigured or something ?
<FromGitter> <sdogruyol> @unshadow you can open an issue on the repo
<RX14> does it fail on their local test suite?
<FromGitter> <fridgerator> they're using old versions of everything
<FromGitter> <sdogruyol> let me check the repo
<RX14> maybe i'll have a stab at redoing everything from scratch...
<RX14> i would if it was +1 week
<FromGitter> <sdogruyol> why from scratch
<RX14> because it's small enough to do so
blort has quit [Quit: Leaving]
akwiatkowski has quit [Ping timeout: 240 seconds]
<FromGitter> <sdogruyol> meanwhile this is the source of the benchmark https://github.com/TechEmpower/FrameworkBenchmarks/tree/master/frameworks/Crystal/kemal
<FromGitter> <sdogruyol> it's pretty outdated and uses crystal-pg not crystal-db
<RX14> but i don't think the complete failures are due to it being old crystal
<RX14> as long as the crystal versions are pinned
<FromGitter> <sdogruyol> yeah
<RX14> they are
<RX14> so no idea why it would fail
<FromGitter> <sdogruyol> weird
snsei has joined #crystal-lang
unshadow has quit [Quit: leaving]
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<RX14> using SO_REUSEPORT support should put us above go
<FromGitter> <sdogruyol> makes sense
skinkitten has quit [Read error: Connection reset by peer]
<FromGitter> <sdogruyol> but still even without that it's weirdly low
<RX14> yes it doesn't get any
<RX14> on the preview
<RX14> it 100% fails
<RX14> it's not weirdly low for performance reasons, it's just broken
<FromGitter> <sdogruyol> have you checked other results like multiple updates, fortune e.g
<FromGitter> <sdogruyol> those are working but really low
<RX14> i did a crystal language filter
<RX14> and only got 1 result
<RX14> for kemal
<FromGitter> <sdogruyol> there are tabs above
<RX14> oh...
<FromGitter> <sdogruyol> test types
<RX14> thats really bad web design
<FromGitter> <sdogruyol> yeah really hard to find
<FromGitter> <sdogruyol> check json serialization
<FromGitter> <sdogruyol> it's really low
<FromGitter> <sdogruyol> 12,200 smth i expect at least 100-200k
<RX14> yeah based on local results it's just weirdly slow
<FromGitter> <sdogruyol> does it have to do with LLVM version
<RX14> i doubt it
<RX14> check these errors
<domgetter> Am I misunderstanding macros, or should this work? https://gist.github.com/domgetter/c3d3c65d1bec532bc3917fb8eafb6f28
<FromGitter> <sdogruyol> that's not good
<FromGitter> <asterite> The macro expands to that, but it's expanded outside struct Int...
skinkitten has joined #crystal-lang
<domgetter> ah okay. I thought it was placing the result inside the Int struct
<RX14> it might just be that being single-threaded is killing crystal because their CPU has terrible singlecore performance
<RX14> they have 80 threads
<RX14> but terrible singlecore
snsei has quit [Read error: Connection reset by peer]
<RX14> and we still get 50k
snsei has joined #crystal-lang
Qchmqs has quit [Ping timeout: 240 seconds]
<crystal-gh> [crystal] bcardiff pushed 1 new commit to master: https://git.io/vStKE
<crystal-gh> crystal/master 6a45e08 TSUYUSATO Kitsune: Flate: try to inflate even if @stream.avail_in is 0 (#4193)...
<crystal-gh> [crystal] bcardiff closed pull request #4193: Flate: try to inflate even if @stream.avail_in is 0 (master...fix/flate/reader-believe-stream-end) https://git.io/vSky1
sz0 has joined #crystal-lang
skinkitten has quit [Read error: Connection reset by peer]
mark_66 has quit [Remote host closed the connection]
Kug3lis_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rmosolgo has joined #crystal-lang
<travis-ci> crystal-lang/crystal#6a45e08 (master - Flate: try to inflate even if @stream.avail_in is 0 (#4193)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/215586241
<DeBot> https://github.com/crystal-lang/crystal/pull/4193 (Flate: try to inflate even if @stream.avail_in is 0)
Raimondi has quit [Read error: Connection reset by peer]
<rmosolgo> Hi, I'm hoping to express "the number of times something can happen", something like Range(Int, Int), but _infinity_ is a possible option. The only INFINITY I could find in Crystal was `Float64::INFINITY`, does this mean I should use `Range(Float64, Float64)` in this case?
Raimondi has joined #crystal-lang
<rmosolgo> Oh, I think Int32::MAX will do the job :)
snsei_ has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
domgetter has quit [Ping timeout: 260 seconds]
snsei_ has quit [Remote host closed the connection]
gloscomb1 has quit [Ping timeout: 260 seconds]
gloscombe has joined #crystal-lang
Renich__ has joined #crystal-lang
emancu has joined #crystal-lang
Renich has quit [Ping timeout: 256 seconds]
Renich__ is now known as Renich
Renich has quit [Quit: Renich]
<kodo[m]> Crystal has made me start toying with c seriously for the first time. I'm quickly discovering why pointers are evil. Heh you get an object back Everytime but where it points is anyone's guess
<kodo[m]> Makes it super hard to debug
emancu has quit []
<kodo[m]> Debugging shared libraries for crystal is a serious pain
<kodo[m]> Heh
* kodo[m] goes back to his corner
domgetter has joined #crystal-lang
domgetter has quit [Quit: Leaving]
sz0 has quit [Quit: Connection closed for inactivity]
akwiatkowski has joined #crystal-lang
Renich has joined #crystal-lang
<Papierkorb> kodo[m]: Mh? Pointers are in every language out there
<RX14> Papierkorb, the implication is raw pointers/pointer arithmetic
rmosolgo has quit []
<Yxhuvud> Papierkorb: Pointers that can maybe not point to something is definitely not in every language
<Renich> Personas, do we have pretty print in crystal?
<Papierkorb> Renich: Just use the `pp` macro if you just want to dump object(s) to STDOUT for debugging
<Renich> Papierkorb: oh, so it works without requiring "pretty_print"?
<Papierkorb> Yeah it just works :)
<Renich> Papierkorb: awesome! ;)
* Renich is starting to love crystal
<Renich> I mean, I loved it already; but it keeps getting better
<FromGitter> <Sija> yep. it’s like hello, my name is Sija and i’m and addict, already.
<Renich> Sija: o/
<FromGitter> <Sija> soon some social org will air some ads about the “New craze found on the streetz of internetz, they call it Crystal"
gloscombe has quit [Ping timeout: 264 seconds]
manveru has quit [Ping timeout: 255 seconds]
manveru has joined #crystal-lang
canta1 has joined #crystal-lang
canta has quit [Ping timeout: 258 seconds]
bjz has joined #crystal-lang
canta1 has quit [Quit: WeeChat 1.7]
canta has joined #crystal-lang
avdi has quit [Ping timeout: 255 seconds]
avdi has joined #crystal-lang
<Renich> Sija: @men to that!
<Renich> So, here's me; trying to consume an API. Any recommendations?
<Renich> json_load?
<FromGitter> <Sija> @Renich see https://crystal-lang.org/api/0.21.1/JSON.html
<Renich> Sija: am right there
<Renich> Sija: thanks
<Renich> So, I fetch some JSON using HTTP::Client or just the JSON module? I mean, an IO could be some URL?
<Renich> Also, I am interested in having something similar to pry or IRB... crystal play seems like too much
NIk-- has joined #crystal-lang
<RX14> Renich, because of crystal's type system it's pretty hard to make something like pry/irb
<Renich> RX14: OK, got it. No problem. I can always write a small test.cr
<RX14> because types flow across almost the whole program it's basically impossible to incrementally run code
<Renich> Just for isolated tests
<RX14> but there have been hacks that do stuff like this
<RX14> ike icr which just runs the whole file each time
<RX14> just appends a line interactively
<RX14> but thats unmaintained iirc
<Renich> RX14: oh, OK
<RX14> it's a hack
<Renich> don't worry, I just wanted to know if it was possible
<RX14> crystal play is probably your best bet
<RX14> as for JSON, you need to use HTTP::Client
<RX14> the JSON module only deals with json
<Renich> RX14: got it. Maybe I just have to get my head around it
<Renich> RX14: Thanks again, man!
<RX14> something like HTTP::Client.get("url") do |response|; JSON.parse(response.body)...; end
<RX14> and eventually you'll probably want to use JSON.mapping
<Renich> RX14: btw, crystal-icr has commits on Jan 14... just sayin'
<RX14> thats practically unmaintained at crystal pace
<Renich> RX14: yeah, I will probably
<RX14> for something which depends on the compiler
<Renich> RX14: yeah, you're right ;)
<Renich> RX14: you're very kind. Thanks a lot for the help
<RX14> no problem
<FromGitter> <dmitryck> the new site of crystal-lang has been published today?
<FromGitter> <mverzilli> no, on Thursday IIRC
<FromGitter> <jwoertink> Has anyone written any tutorials or posts about how to read a .h file and pull that in to crystal?
<FromGitter> <dmitryck> @mverzilli got it
<FromGitter> <elorest> I'll work on that. I've been doing a ton with c libs in the last few weeks. so writing down what I've learned would be a good idea.
<FromGitter> <KCreate> Is it possible to dynamically get the number of bytes a class takes up? For example `Int32 : 4` `Int64 : 8` `Int8 : 1`
<FromGitter> <mverzilli> have you tried https://github.com/crystal-lang/crystal_lib?
<FromGitter> <KCreate> Something like this: ⏎ ⏎ ```foo = Int32 ⏎ foo.amount_of_bytes # => 4``` [https://gitter.im/crystal-lang/crystal?at=58d978d1f22385553de1423e]
Ven has joined #crystal-lang
Ven is now known as Guest82746
<FromGitter> <KCreate> No because that doesn't work dynamically
<FromGitter> <KCreate> I am assigning class names to variables and need to know how many bytes they take up
<FromGitter> <elorest> <RX14> Could you look at my commend on your answer in stack overflow. I got it to work but wrapping the spawn in a proc. As it currently is you can only connect to it with one client at once because `socket.close` in one fiber closes it for all the others as well. http://stackoverflow.com/questions/43032865/how-would-i-set-up-a-simple-unix-socket-server-in-crystal-that-could-communicate ⏎ ⏎ I'll mark it as the correct answer
<FromGitter> ... as soon as it reflects that or shows another way to solve that issue. Thanks again.
<RX14> socket.close only closes the one socket
<RX14> plus there's no socket.close in the only version which spawns
<RX14> and there's no need for procs
<RX14> an error message would help
<FromGitter> <KCreate> @mverzilli Actually no, that does work for me, Thanks! See: https://carc.in/#/r/1rxd
<FromGitter> <mverzilli> yeah, I was checking the #class docs: https://crystal-lang.org/api/0.21.1/Object.html#class-instance-method
<FromGitter> <mverzilli> glad it worked :)
<FromGitter> <elorest> <RX14> ```
<FromGitter> <elorest> Ok. So I guess you're saying that I don't want to close it. I'll remove that and try. thanks
<RX14> no, you want to close it
<RX14> can you show me the code with that error message
<FromGitter> <elorest> in that gist that I sent over if you comment out the proc and proc.call it will error if you start two clients, send the name to one and then try to send it to the other.
<RX14> the server works perfectly for me
<FromGitter> <elorest> <RX14> So if you start the server... then open two more terminal/tmux windows and run client in both of them at the same time, then send the name through one, it doesn't error on the server side when you send it through on the second?
<RX14> nope
<RX14> there does seem to be a bug with variable binding though
<RX14> ohh
<RX14> there's some weird codegen bug here
<RX14> I managed to get a Bad file descriptor Errno
<FromGitter> <elorest> In the docs it says this with Int32 being passed into 10 spawns so I figured it would be the same here. https://dl.dropboxusercontent.com/s/famkpnadi0p3cys/2017-03-27%20at%203.01%20PM.png
Guest82746 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<RX14> reproduced: https://carc.in/#/r/1rxp
<RX14> that shouldn't happen
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<BlaXpirit> RX14, why not?
<RX14> because it switches out the container under the fiber
<RX14> if the assign was outside the loop i'd understand
<BlaXpirit> what's the difference
<RX14> but inside the loop should be it's own scope with each binding being a new variable
<BlaXpirit> seems exactly like the interaction of a closure with a loop variable
Ven_ has joined #crystal-lang
<BlaXpirit> or rather lack of closure
<RX14> but it's not assigned to an existing variable, it's a new variable
<RX14> so it should be scoped to each loop iteration
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven_ has joined #crystal-lang
sz0 has joined #crystal-lang
Ven_ has quit [Client Quit]
<FromGitter> <jwoertink> How would I reference from C `typedef struct _Thing Thing;` in a Crystal Lib?
<FromGitter> <jwoertink> or would Crystal just pick that up from the Link and allow me to just call `Thing` directly?
<FromGitter> <elorest> I don't think you would. You would just redefine it in crystal and if the contents matched up it will work.
<RX14> well struct definitions aren't part of the exported symbols
<FromGitter> <jwoertink> so it would be ```
<RX14> you just have to define the same struct and call it whatver you want
<FromGitter> <jwoertink> ```struct Thing ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=58d986198fcce56b20a3d819]
<FromGitter> <jwoertink> I see some that say `typedef struct Whatever {` then list a bunch of declarations inside those curly braces, but in this case, there's no curly braces. I assume it's actual definition is probably somewhere else....
<FromGitter> <elorest> @jwoertink This might help. https://gist.github.com/elorest/76831e95c5c14a72df6407a152a20916
<FromGitter> <jwoertink> Ok, so that makes sense for the ones that declare things, but what about ones that don't? Like if it were `typedef struct _Person Person;`
<FromGitter> <jwoertink> I would just do ...``` ⏎ lib LibSay ⏎ struct Person ⏎ end ⏎ end ... [https://gitter.im/crystal-lang/crystal?at=58d987204cb8d0917331f64b]
<FromGitter> <elorest> Same thing. In that case your just creating a type from an existing struct.
<FromGitter> <jwoertink> lol formatting ~_~
<FromGitter> <jwoertink> ok cool. I'll try that out. Thanks!
<RX14> `typedef struct _Person Person` simply defines `Person` to be `struct _Person`
<RX14> so you're looking for the _Person struct definition
<FromGitter> <elorest> You need to figure out where _Person was defined at.
<RX14> which is referenced by either `struct _Person` or `Person` in the code
<Renich> What are those {% ... %} things? Compiler logic?
<Renich> I am trying to consume an API so, maybe, I could do something similar for all the actions I can take
<FromGitter> <elorest> <Renich> Those are macro calls.
<FromGitter> <jwoertink> Ok, cool. I guess this struct is actually defined somewhere else, I just gotta find that code
<FromGitter> <fridgerator> I'm assuming there is a method to url encode a string but I'm not finding it in the api docs, does anyone know what it is off the top of their head?
<Renich> @elorest: OK. I'll read into macros
<Renich> what about the getter keyword at the top. Does that, really, generate a getter?
<FromGitter> <elorest> @jwoertink yep. I've ran into that a few times too. Just grep the .h and .c files.
<RX14> @fridgerator you want URI.escape
<FromGitter> <jwoertink> :thumbsup: sweet.
<FromGitter> <fridgerator> there it is, thanks @RX14
<FromGitter> <elorest> <Renich> Yep.
<Renich> @elorest: awesome. Thanks
<FromGitter> <jwoertink> Yeah, I'd love to see some sort of "cheat sheet" guide for doing a 1 to 1 mapping between a C lib and writing a Lib in Crystal
<RX14> well
<RX14> to be honest, if you don't know C I wouldn't recommend binding
<FromGitter> <jwoertink> lol
<RX14> there's lots more to bindings than syntax
<RX14> to call C you need to know C semantics
<RX14> and things not to do, like dangling pointers
<FromGitter> <jwoertink> true. There's definitely a lot to learn.
<FromGitter> <jwoertink> I picked up Java by porting a bunch of a Java libs over to JRuby. I was hoping this could be my gateway in to learning C
<kodo[m]> I spent 8 hrs trying to bind a c library for fun
<kodo[m]> was horrible and awesome at the same time
<FromGitter> <elorest> I've pretty much just taken my C++ skills and deleted most of them and relearned pointers.
<kodo[m]> learned a lot about c
<kodo[m]> the #1 thing it did was make me really thankful for crystal
<FromGitter> <jwoertink> Unfortunately I have no C++, C, or any other single letter programming language skills.
<FromGitter> <elorest> Sometimes I write c and think wow if ruby ever dies and crystal doesn't replace it I'll probably just do c. Not that I'm an expert but it really doesn't seem that bad.
<FromGitter> <jwoertink> If Ruby dies and Crystal doesn't replace it, I'm opening a taco truck and pulling a _why
<RX14> hah
<FromGitter> <elorest> lol
<FromGitter> <elorest> Foxes.
<FromGitter> <ltran> Anyone here played with protobuf3?
<FromGitter> <jwoertink> chunky bacon
<FromGitter> <ltran> my company is moving towards it and i want the option to write my scripts in crystal ;D
<kodo[m]> jwoertink: amen LOL
<FromGitter> <matrixbot> `kodo 🌍` Test
<FromGitter> <matrixbot> `kodo 🌍` woo hoo my own private gitter bridge on matrix heh
<FromGitter> <tjgillies> the gitter native client is kinda nice though
kodo[m] has left #crystal-lang ["User left"]
<RX14> oh great
<RX14> <FromGitter> <matrixbot> `kodo 🌍` Test
<RX14> thats readable
<FromGitter> <elorest> It's like xml
<FromGitter> <matrixbot> `kodo 🌍` xml is like violence, if it's not working you're not using enough
<FromGitter> <matrixbot> `Dybbuk` Wait...what is this chat thing?
<FromGitter> <matrixbot> `kodo 🌍` Dybbuk: This is the crystal language gitter matrix bridge. I drugged you and brought you here against your will. You're welcome
<FromGitter> <matrixbot> `Dybbuk` I wish I could say that was the first time a Crystal had done that to me.
MatrixTraveler[m has joined #crystal-lang
<crystal-gh> [crystal] MakeNowJust opened pull request #4201: Colorize: remove Colorize::Object#inspect (master...fix/colorize/remove-inspect) https://git.io/vSqDD
mjago has joined #crystal-lang
<FromGitter> <elorest> So since both of these compile and work is there a tool that will turn example1 into example2. ⏎ ⏎ ```#example2 ⏎ def square(x : Int32) Int32 ⏎ x*x ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=58d99411b402a53211bb7fff]
<RX14> what do you mean?
<FromGitter> <elorest> Does something exist similar to a formatter that could add variable types if they're missing? Theoretically this is possible since the compile knows and inserts them at compile time if they're missing.
NIk-- has quit [Quit: Textual IRC Client: www.textualapp.com]
<FromGitter> <ltran> golang.org/x/net
<RX14> @elorest argument types are inferred from every call of the method so you'd need code that calls it and you couldn't be sure it's correct
<RX14> if you don't want to write the argument types just don't write them
<RX14> i rarely write them
<FromGitter> <elorest> K
<FromGitter> <jwoertink> I see some examples in this header file that have something like `int x` which is translated in crystal as `x : LibC::Int`. I then saw something that said `y Uint8` so I assumed that was `LibC::UInt8`, but that throws a `undefined constant LibC::UInt8`...
<FromGitter> <jwoertink> Would I just use the normal `UInt8` constant for that?
<FromGitter> <elorest> UInt8 is great for an 8bit unsigned int. usually they seem to be used for chars*
<FromGitter> <jwoertink> Yeah, there's a few that are used like that, but not all of them (in this case at least)
<FromGitter> <elorest> Can you show me an example?
<FromGitter> <jwoertink> ah
<FromGitter> <jwoertink> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58d99c0b08c00c092a20a9e8]
<FromGitter> <jwoertink> so looks like for `volume` I can just do `LibC::Char`,
<FromGitter> <matrixbot> `kodo 🌍` I usually just copy whatever the c lib is using
<FromGitter> <matrixbot> `kodo 🌍` I think they are aliased so they there is consistency with what you're binding
<FromGitter> <matrixbot> `kodo 🌍` that there*
<FromGitter> <elorest> ```struct Mix_Chunk{ ⏎ abuf : UInt8* ⏎ alen : UInt32 ⏎ volume: UInt8 ⏎ }``` [https://gitter.im/crystal-lang/crystal?at=58d99cb2408f90be66614b1d]
<FromGitter> <elorest> That should work.
<FromGitter> <jwoertink> you mean without the curly braces? ;)
<FromGitter> <elorest> Yeah and indenting...
<FromGitter> <jwoertink> haha. cool
<FromGitter> <jwoertink> thanks
<FromGitter> <fridgerator> what is matrixbot?
<FromGitter> <jwoertink> I think it's from this https://matrix.org/
<FromGitter> <matrixbot> `kodo 🌍` matrix bot is the matrix/gitter bridge
<FromGitter> <matrixbot> `kodo 🌍` posted an image: ((http://matrix.org/_matrix/media/v1/download/tyler.cat/mHfFIIvnYSGEqggDUsgMFBwb))
<FromGitter> <tjgillies> no lightbox on images?
<FromGitter> <tjgillies> meh
sz0 has quit [Quit: Connection closed for inactivity]
txdv has quit [Ping timeout: 240 seconds]