jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.18.7 | Fund Crystals 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
mgarciaisaia has joined #crystal-lang
_jaitaiwan has joined #crystal-lang
<_jaitaiwan> BlaXpirit: Thanks for the pointer with the innheritance issue. Looks like I can't push an un-init class onto the Array
pawnbox has joined #crystal-lang
vrand has joined #crystal-lang
<azrad> Hi, noob here. I noticed something that seemed odd in crystal, with a program spread across two files (where file 1 requires file 2). It seems that some libraries used by file 2, must be "required" by file 2, and other libraries used by file 2 can be "required" by file 1. example: https://gist.github.com/anonymous/6ee2e8ebb2512adfc3dd14c1abf40edb not sure if this is a bug, or just unexpected behavior, or working as intented. Any
pawnbox has quit [Ping timeout: 276 seconds]
Philpax has quit [Ping timeout: 252 seconds]
<FromGitter> <drosehn> Hmm. Isn't `test2.cr` compiled when it is included? And I assume that the compiler expects to compile it before proceeding to the next line (the `require "http/client"` in this case). What happens if you put the `require "json"` before the `require "./test2.cr"` ?
<FromGitter> <drosehn> Note that I have only a little experience with crystal, so I'm just guessing here.
vrand has quit [Remote host closed the connection]
<azrad> I'll give it a try!
vrand has joined #crystal-lang
<azrad> ah ha! you are right, if you "require" it in main.cr before the require for test2.cr it works.... thanks
<azrad> and now it makes sense to me, thanks agin
<FromGitter> <drosehn> sure. glad that it was a good guess. :)
_jaitaiwan has quit [Ping timeout: 264 seconds]
vrand has quit [Ping timeout: 244 seconds]
vrand has joined #crystal-lang
mgarciaisaia has quit [Quit: Leaving.]
vrand has quit [Quit: Mutter: http://www.mutterirc.com]
vrand has joined #crystal-lang
Renich has quit [Quit: leaving]
vrand has quit [Client Quit]
Philpax has joined #crystal-lang
vrand has joined #crystal-lang
vrand has quit [Remote host closed the connection]
<wmoxam> Is there a way to alias a method in a c binding? IE: a function in a c lib is named different in one OS vs another but I want to present an identical interface
<crystal-gh> [crystal] Sija opened pull request #3194: Use Exception#message getter instead of @ivar to allow overloading (master...patch-1) https://git.io/v6dQ4
<FromGitter> <Sija> @wmoxam: yup, just do `fun <your-name> = <original-name>` — see https://crystal-lang.org/docs/syntax_and_semantics/c_bindings/fun.html
<wmoxam> ohhh, totally missed that. Thanks Sija!
<FromGitter> <Sija> yw!
Philpax has quit [Ping timeout: 244 seconds]
Oliphaunte has joined #crystal-lang
mgarciaisaia has joined #crystal-lang
Oliphaunte has quit [Read error: Connection reset by peer]
Oliphaunte has joined #crystal-lang
Philpax has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
woops has joined #crystal-lang
pawnbox has joined #crystal-lang
woops has quit [Ping timeout: 264 seconds]
Oliphaunte has quit [Remote host closed the connection]
pawnbox has quit [Remote host closed the connection]
azrad has quit [Quit: Page closed]
tomchapi_ has joined #crystal-lang
tomchapi_ has quit [Client Quit]
pawnbox has joined #crystal-lang
<FromGitter> <KingPixil> Hey guys, is there a basic chat example using no library with Crystal websockets?
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Davy_CC has quit [Ping timeout: 252 seconds]
bjz has joined #crystal-lang
Davy_CC has joined #crystal-lang
steenuil has quit [Quit: Textual IRC Client: www.textualapp.com]
Philpax has quit [Ping timeout: 250 seconds]
kulelu88 has quit [Quit: Leaving]
Philpax has joined #crystal-lang
txdv has quit [Quit: WeeChat 1.0.1]
txdv has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
willl has quit [Quit: Connection closed for inactivity]
ome has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<BlaXpirit> I'm hacking on the compiler's parser - how to obtain the original source code of the expression that I just parsed?
<BlaXpirit> ah I could save the old pos
bjz has joined #crystal-lang
bjz has quit [Read error: Connection reset by peer]
bjz has joined #crystal-lang
mark_66 has joined #crystal-lang
<BlaXpirit> welp, I implemented the whole thing, but of course something is wrong https://github.com/crystal-lang/crystal/commit/4a0262fc
<BlaXpirit> Bug: `---whole prelude here--- assert 1 == 2` at has no type
<BlaXpirit> no idea what to do about this
<BlaXpirit> proper traceback: https://bpaste.net/show/f4df2166e17e (note that these are my changes that are bugging out)
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<BlaXpirit> heh, I tried out "assert 1==2; p 6" instead and got an entirely different, very useful error message
bjz has joined #crystal-lang
<BlaXpirit> now i got Bug: Unless node '...' should have been eliminated in normalize
<BlaXpirit> next up: "Bug: already had enclosing call"
matp has joined #crystal-lang
onethirtyfive has joined #crystal-lang
ome has quit [Quit: Connection closed for inactivity]
Philpax has quit [Ping timeout: 258 seconds]
Philpax has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
pataphysics has quit [Ping timeout: 244 seconds]
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
pataphysics has joined #crystal-lang
bjz has joined #crystal-lang
matp has quit [Ping timeout: 240 seconds]
tomchapi_ has joined #crystal-lang
tomchapin has quit [Ping timeout: 276 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
pawnbox has quit [Remote host closed the connection]
ome has joined #crystal-lang
soveran has quit [Remote host closed the connection]
jamie_ca has quit [Ping timeout: 258 seconds]
DeBot has quit [Ping timeout: 260 seconds]
bjmllr has quit [Ping timeout: 250 seconds]
jhass has quit [Ping timeout: 250 seconds]
asterite has quit [Ping timeout: 258 seconds]
bjmllr has joined #crystal-lang
asterite has joined #crystal-lang
jamie_ca has joined #crystal-lang
jhass has joined #crystal-lang
mkl0502 has joined #crystal-lang
bjz has joined #crystal-lang
Oliphaunte has joined #crystal-lang
matp has joined #crystal-lang
bjz has quit [Ping timeout: 276 seconds]
bjz has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 276 seconds]
DeBot has joined #crystal-lang
matp has quit [Ping timeout: 244 seconds]
Oliphaunte has quit [Remote host closed the connection]
soveran has joined #crystal-lang
Oliphaunte has joined #crystal-lang
perks has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
perks has quit [Quit: perks]
Oliphaunte has quit [Ping timeout: 264 seconds]
mgarciaisaia has joined #crystal-lang
mgarciaisaia has quit [Ping timeout: 244 seconds]
mgarciaisaia has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
<jeromegn> I can’t figure out this memory access issue. I’m trying to create a zookeeper c lib bindings, but I get a weird error: https://gist.github.com/jeromegn/113d18e01e7b92bdd85c2c0917258ab7
<jeromegn> I’ve attempted giving a minimal example in that gist ^
<jeromegn> basically, getting a value returns all the right things as I inspect them within the method, but there’s a memory access error between when it returns the value and my example program consuming it (just to print it)
Oliphaunte has joined #crystal-lang
<jeromegn> I tried a lot of variations, I used the `out` keyword before and it made things worse. With `out`, I was not getting the full node value, it was cut from the beginning. When I stopped using `out`, at least I could inspect the full value
<jeromegn> in my experience memory problems with bindings is usually a problem with badly defined bindings, that don’t match the C definitions. In this case, they seem to match, no?
<jeromegn> this may be too long a question for IRC :)
perks has joined #crystal-lang
<BlaXpirit> jeromegn, wat
<BlaXpirit> i think you're telling it to write a string but you point it to a single byte
<BlaXpirit> referring to 'buffer' variable
<jeromegn> mmm
<BlaXpirit> so it kinda seems to work right afterwards
<BlaXpirit> but the stack is totally busted
mkl0502 has left #crystal-lang [#crystal-lang]
<jeromegn> isn’t that what it wants though? from the function signature: `char *buffer`
<BlaXpirit> jeromegn, does this thing have any good documentation?
<jeromegn> it has docs inline
<jeromegn> I can add them to the gist
<jeromegn> but no real usage docs
<BlaXpirit> oh good, it has source cod
<BlaXpirit> i don't know how you're supposed to choose the buffer size, but this should work:
<jeromegn> they sort of give us the buffer size afterwards :(
<BlaXpirit> buffer = uninitialized UInt8[1024]
<jeromegn> ah
<BlaXpirit> buffer_len 1024
<jeromegn> I did see example code that set that to 512
<jeromegn> but it’s not documented :(
<BlaXpirit> pointerof(buffer) change to buffer
<BlaXpirit> String.new(buffer.to_slice(buffer_len))
<jeromegn> buffer_len is something that the implementation populates
<BlaXpirit> jeromegn, it both reads and populates..
<BlaXpirit> first it's probably used as a max to avoid buffer overflow, but then it's also populated with "actually read"
<jeromegn> ah
<jeromegn> interesting
<BlaXpirit> C is very "interesting"
Oliphaunte has quit [Remote host closed the connection]
<jeromegn> that did work, thanks a lot BlaXpirit :)
<jeromegn> had to convert to slice before selecting the characters given StaticArray#to_slice does not accept arguments.
<BlaXpirit> huh i'm not sure what you did
<jeromegn> String.new(buffer.to_slice[0, buffer_len])
<BlaXpirit> oh, that's quite nice. i was going to suggest buffer.to_unsafe.to_slice(buffer_len) works
<jeromegn> "The maximum allowable size of the data array is 1 MB (1,048,576 bytes). Arrays larger than this will cause a KeeperExecption to be thrown."
Oliphaunte has joined #crystal-lang
<jeromegn> ah
soveran has quit [Remote host closed the connection]
Oliphaunte has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
<jeromegn> BlaXpirit: any tip on how I should decide what value to use for that static array? UInt8[1024]. How do I determine what’s a good limit here?
ome has quit [Quit: Connection closed for inactivity]
<FromGitter> <deepj> Is there any chance to use Crystal on AWS Lambda? Any luck or experiences?
<FromGitter> <kofno> You can launch native code on lambda w/ a small node js wrapper. After that, it kind of depends on what your native dependencies are.
perks has quit [Quit: perks]
<BlaXpirit> jeromegn, i have no idea. C is full of such arbitrary limits
<jeromegn> according to the zookeeper docs, a znode’s data can be up to 1 MB
<jeromegn> but I don’t know if that matters or even translate to a size of StaticArray
<BlaXpirit> jeromegn, well translating is easy, it's 1024*1024
<BlaXpirit> but i dont know
<jeromegn> that seems huge though :)
<RX14> allocating a StaticArray of 1024*1024?
Oliphaunte has joined #crystal-lang
<jeromegn> yea...
soveran has quit [Remote host closed the connection]
<RX14> why not a Slice?
<RX14> StaticArray is on the stack
<RX14> 1MB seems a little big for the stack
<jeromegn> yea
<jeromegn> hmm
<RX14> i'm not 100% sure what you're doing
<jeromegn> using a slice with no specified size seems to work… weird
<BlaXpirit> "gets the data associated with a node synchronously."
<BlaXpirit> jeromegn pls
<jeromegn> hehe, I explained above, but it’s a long explanation
<RX14> jeromegn, you can't have a slice with no size...
<jeromegn> BlaXpirit: I went the simplest route for now, I still need to figure out how to do that async
<jeromegn> uninitialized Slice(UInt8)
<BlaXpirit> jeromegn, it's a slice of random size in random memory location
<jeromegn> ah
<BlaXpirit> not literally random but i think u get the idea
<jeromegn> ok, I initialized it instead with the limit size
<jeromegn> yea
<RX14> you want Slice.new
<RX14> uninitialized slice will just create a Slice struct without the pointer
<jeromegn> BlaXpirit: about that sync vs async thing… I’m not sure how to handle it really… fibers? kinda want to return the value from that call as if it was synchronous
<RX14> well how does the async call work?
<BlaXpirit> when two worlds with different async paradigms clash, that usually involves a busy loop
<RX14> where's these docs?
<BlaXpirit> nowhere lol
matp has joined #crystal-lang
<RX14> well
<RX14> you can call that, pause the current fiber, then resume in the callback
<RX14> like the IO does
<BlaXpirit> but how can a callback work in one thread? is this explicitly threaded?
<RX14> actually i really don't know how libevent works
<RX14> is the libevent loop in a different thread?
<jeromegn> multi threaded yes
<jeromegn> ^ not an answer to the last question
<jeromegn> BlaXpirit: zookeeper provides 2 implementations, single and multi threaded. I’m using the multi threaded one
<BlaXpirit> RX14, who knows. well libevent doesnt need a thread, i can guess that it's an event loop based on context switching, which is done based on 'select'
Oliphaunte has quit [Read error: Connection reset by peer]
<RX14> oh i see how it works
<RX14> there's a fiber that ruuns the libevent event loop
<RX14> and because the callbacks happen on the event loop fiber
<RX14> the scheduler works properly
<BlaXpirit> callbacks don't directly execute code, that's the secret
<RX14> what do you mean?
<BlaXpirit> a function in a fiber does something, and tells the event loop it's finished, and the event loop resumes a different fiber
<BlaXpirit> that is nice stuff
<RX14> yes
<BlaXpirit> while multithreaded stuff starts a new thread and does the callback in that thread. that is not nice
<RX14> yes
Oliphaunte has joined #crystal-lang
<RX14> it would be nicer if the scheduler was threadsafe
<RX14> then we could have a reschedule_later that could be called from different threads
<RX14> so you could just tell the scheduler to resume fiber x next at some time in the future
<BlaXpirit> thread safety is always one lock away xD
<RX14> well if you want to patch the scheduler...
Oliphaunte has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
xmgx has joined #crystal-lang
Philpax has quit [Read error: Network is unreachable]
Philpax has joined #crystal-lang
mgarciaisaia has joined #crystal-lang
Oliphaunte has joined #crystal-lang
mgarciaisaia1 has joined #crystal-lang
mgarciaisaia has quit [Read error: Connection reset by peer]
azrad has joined #crystal-lang
mgarciaisaia has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
mgarciaisaia1 has quit [Ping timeout: 252 seconds]
mgarciaisaia has left #crystal-lang [#crystal-lang]
soveran has joined #crystal-lang
<BlaXpirit> i have yet to benchmark it tho xD
<BlaXpirit> well, this is the real meat https://bpaste.net/show/ed84b3c83c44
<BlaXpirit> real proud about that `||raise` usage
Oliphaunte has joined #crystal-lang
mark_66 has quit [Remote host closed the connection]
<BlaXpirit> alright. benchmark with all the asserts triggering: before - 0m20.391s, after - 0m23.556s
Oliphaunte has quit [Remote host closed the connection]
<BlaXpirit> benchmark without asserts triggering: before - 0m14.010s, after - 0m20.228s :<
<BlaXpirit> power_assert: a few minutes and going
Oliphaunte has joined #crystal-lang
soveran has quit [Remote host closed the connection]
Philpax has quit [Ping timeout: 264 seconds]
Oliphaunte has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
<RX14> BlaXpirit, you're benchmarking compile?
<BlaXpirit> oh now that i think about it, same code with power_assert: 25m23.166s :D
<RX14> yeah
<RX14> well
<BlaXpirit> RX14, what do you mean?
<RX14> are you benchmarking compile time
<RX14> right
CompanionCube has quit [Ping timeout: 264 seconds]
CompanionCube has joined #crystal-lang
<BlaXpirit> RX14, well seems like it's compile time
<BlaXpirit> i just did `time crystal asdf.cr`
<BlaXpirit> run time is almost the same though. 26.97 milliseconds / 26.27 milliseconds (compiler assert) / 27.57 milliseconds (power_assert)
matp has quit [Ping timeout: 276 seconds]
<RX14> BlaXpirit, well
<RX14> how many asserts was that
<RX14> just the 4?
<jeromegn> think I figured out async get for zookeeper: https://gist.github.com/jeromegn/703c701a6c55af0409718f9e579fcc03
<jeromegn> does that make sense?
<BlaXpirit> RX14, i had a collection of those 4 asserts so it was {%for 100%} 4 tests with failing asserts {%end%}
<BlaXpirit> no, wait
<BlaXpirit> {%for 1000%} 4 tests with failing asserts {%end%}
<RX14> oh ok
<RX14> so 4k
<BlaXpirit> and for the non-failing tests, that would be {%for 200%}46 asserts (json/any_spec.cr){%end%}
soveran has quit [Remote host closed the connection]
<BlaXpirit> anyhow, the takeaway is that compile time seems to be 30% longer
<BlaXpirit> what next actions?
<BlaXpirit> not that it matters because crystal repository is dead quiet :o
<RX14> is that vs vanilla specs?
<BlaXpirit> RX14, yes
<RX14> well
<RX14> 30% larger
<RX14> hmm
<BlaXpirit> same compiler running vanilla specs with DSL and equivalent tests changed to assert
<RX14> does that scale linearly?
<BlaXpirit> ugh i have no idea
<RX14> BlaXpirit, put the benchmark on github and link your branch and see what asterite has to say about if you can speed up the compiler code.
Oliphaunte has joined #crystal-lang
<BlaXpirit> the way it scales makes absolutely no sense https://gist.github.com/c388f070edf4f4bf11ab146bdc2ac699
soveran has joined #crystal-lang
<BlaXpirit> ok, must have been some anomaly, new results do make sense. yeah it's linear scaling, if not sub-linear
matp has joined #crystal-lang
<BlaXpirit> another fun thing is it acts as a .not_nil!
vikaton has joined #crystal-lang
<BlaXpirit> I wonder whether it's better to see the outputs like power_assert does it hierarchically, or simply right to left. this way it is indeed easier to see but it can be hard to find the root expression
Oliphaunte has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
tomchapin has joined #crystal-lang
Oliphaunte has quit [Read error: Connection reset by peer]
matp has quit [Ping timeout: 250 seconds]
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Read error: Connection reset by peer]
xmgx has quit [Quit: Leaving...]
Oliphaunte has joined #crystal-lang
azrad has quit [Quit: Page closed]
tomchapin has quit [Quit: Textual IRC Client: www.textualapp.com]
<RX14> BlaXpirit, it seems like it makes sense to me: https://aww.moe/hwgxw5.png
<RX14> oh you had different ersults before?
<BlaXpirit> yes. it's in a revision there
<RX14> yeah oops
<RX14> it's slightly exponential
<BlaXpirit> RX14, i mean linear in relation to "spec"
<BlaXpirit> add spec results there and they will be also exponential
<RX14> oh wow
<RX14> i'm a bit stupid
<RX14> i read your results as 2 runs of the power assert
<RX14> not a run of power assert and spec
<BlaXpirit> no wonder, with that crazy line of bash
<RX14> BlaXpirit, https://aww.moe/aon6zu.png
<RX14> BlaXpirit, https://aww.moe/3yq0n5.png
<RX14> well there's the charts
masukomi has joined #crystal-lang
<RX14> BlaXpirit, great work though, i've been putting off diving into the compiler for a while now
masukomi has quit [Client Quit]
onethirtyfive has quit [Remote host closed the connection]
bmcginty has quit [Ping timeout: 240 seconds]
<BlaXpirit> thanks
bmcginty has joined #crystal-lang
Oliphaunte has quit [Read error: Connection reset by peer]
Oliphaunte has joined #crystal-lang
mkl0501 has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
Oliphaunte has quit [Remote host closed the connection]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Oliphaunte has joined #crystal-lang
soveran has quit [Remote host closed the connection]
Oliphaunte has quit [Read error: Connection reset by peer]
vikaton has quit [Quit: Connection closed for inactivity]
Philpax has joined #crystal-lang
mkl0501 has joined #crystal-lang
mgarciaisaia has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
Philpax has quit [Ping timeout: 250 seconds]
<jfontan> do you know if there's an easy way to turn a buffer into a struct?
<jfontan> like memcpy(buffer, &my_struct, sizeof(my_scruct))
<jfontan> well, more like filling a struct with a buffer