ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.31.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
dwdv_ has quit [Ping timeout: 246 seconds]
alexherbo2 has quit [Ping timeout: 245 seconds]
<FromGitter> <Blacksmoke16> @phangs the guide should be good to go now
<FromGitter> <wontruefree> I am having trouble with crystal_lib and a header file from a project I am trying to generate a lib for. Is there a difference between cpp header files and c header files?
<FromGitter> <wontruefree> I am kind of at a loss
<FromGitter> <wontruefree> There is some errors with *attribute* which makes me think it is a cpp problem
chachasmooth has quit [Ping timeout: 246 seconds]
<FromGitter> <christopherzimmerman> Are you trying to link a c lib or a cpp lib?
chachasmooth has joined #crystal-lang
<FromGitter> <watzon> @wontruefree you can't link to a cpp library, you'd have to write a c wrapper for it and then link to that
return0e has quit []
ht_ has joined #crystal-lang
ht_ has quit [Remote host closed the connection]
dwdv_ has joined #crystal-lang
dwdv_ has quit [Ping timeout: 276 seconds]
sagax has joined #crystal-lang
blassin has quit [Quit: The Lounge - https://thelounge.chat]
blassin has joined #crystal-lang
f1refly has joined #crystal-lang
alexherbo2 has joined #crystal-lang
dwdv_ has joined #crystal-lang
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
alexherbo2 has joined #crystal-lang
alexherbo2 is now known as alex```
alex``` has quit [Client Quit]
alexherbo2 has joined #crystal-lang
duane has joined #crystal-lang
coderobe has quit [Read error: Connection reset by peer]
coderobe has joined #crystal-lang
duane has quit [Ping timeout: 240 seconds]
duane has joined #crystal-lang
<FromGitter> <christopherzimmerman> Is there a way to avoid the union return type in a case like this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dd555fdb5e589513e22e422]
<FromGitter> <christopherzimmerman> Currently, I have to have a separate indexing method for both of these cases, which feels a bit clunky.
<FromGitter> <tenebrousedge> there is a union return type in that function. You can use conditionals later to narrow it
<FromGitter> <tenebrousedge> can you return `[3]` for a single result?
<FromGitter> <tenebrousedge> or not use `*` and have two `[]` methods?
<FromGitter> <Blacksmoke16> yea id use two overloads
<FromGitter> <christopherzimmerman> The real problem is that this needs to be generalized for n dimensions, and I don't know how I can do anything other than splat since ndims won't be known at compile time.
<FromGitter> <christopherzimmerman> I kind of like the idea of never actually returning scalars, and instead just returning single element containers.
<FromGitter> <christopherzimmerman> then having a method to convert that to a scalar if the user really needs it.
<FromGitter> <tenebrousedge> :plus1:
duane has quit [Ping timeout: 245 seconds]
<hightower2> crystal-ann seems down
<FromGitter> <christopherzimmerman> @tenebrousedge definitely much more readable. Before I was only accepting an array of integers as an argument if they were after a scalar but it would break if it wasn't the right length, etc.. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dd5592bbebeec417b98b5e8]
<FromGitter> <tenebrousedge> why `item`? why not `t[0, 1, 1][0]` ?
<FromGitter> <christopherzimmerman> That would return the same thing as `t[0, 1, 1]`
<FromGitter> <christopherzimmerman> If I always return tensors from indexing operation.
<FromGitter> <tenebrousedge> hmm. `item` seems odd
<FromGitter> <tenebrousedge> maybe `value`?
<FromGitter> <christopherzimmerman> I like value, because that is what's actually getting returned, just the value of the pointer.
duane has joined #crystal-lang
<FromGitter> <asterite> you can match against `*args : *T` and then check `T.size` at compile-time
<FromGitter> <asterite> Ah, no, there's no way because `@ndims` is a runtime value
<FromGitter> <christopherzimmerman> @asterite is there a reason that `sizeof(Bool)` returns 0? Shouldn't it return 1?
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/81t2 :thinking:
<FromGitter> <asterite> it's fixed in master, will return 1 in the next compiler version
<FromGitter> <tenebrousedge> 👀
<FromGitter> <Blacksmoke16> oh *that* thing again
<FromGitter> <asterite> https://carc.in/#/r/81t5
<FromGitter> <tenebrousedge> interesting
ht_ has joined #crystal-lang
<FromGitter> <wontruefree> @watzon thanks it looks like I have to do that
<FromGitter> <wontruefree> I thought the header file would be universal for some reason
DTZUZU has quit [Ping timeout: 265 seconds]
DTZUZU has joined #crystal-lang
<hightower2> Do I see it right that it's not possible to return more than one value from function without using 'return' explicitly?
<FromGitter> <tenebrousedge> you can return an array or tuple
<hightower2> Ah indeed, tuple seems to work when I do a, b = func, while array doesn't
<FromGitter> <Blacksmoke16> pretty sure they both should
<hightower2> well, the type I get with typeof() gets being different. Let me see if I can put this into a play example
<hightower2> (and either find my mistake or produce a working example :)
<FromGitter> <tenebrousedge> :plus1:
<hightower2> the first one returns what I'd expect
<hightower2> the second one, at a glance I'm not sure why it returns what it does
<FromGitter> <christopherzimmerman> Tuples know what type of element is in each position, arrays do not AFAIK
<FromGitter> <tenebrousedge> correct
<FromGitter> <christopherzimmerman> So you will get the union type if you return the latter.
<hightower2> ah yes, yes,... that's the explanation
<hightower2> well that's what I meant that array didn't work as expected
<hightower2> thanks
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
<hightower2> mm.. so, I have a list of 1500 Procs which are generated dynamically at program startup. I can't keep them in a named tuple because the size limit of the tuples is 300 entries. So I currently have a Hash, but this doesn't know the type of each Proc.
<hightower2> Is there some convenient data structure where I could store them, and have the type of each one known, instead of treating it as an union of all types like a Hash does?
<FromGitter> <Blacksmoke16> could you have a wrapping type?
<FromGitter> <Blacksmoke16> like `Handler(T)`
<FromGitter> <Blacksmoke16> which would be essentially `Hash(String, Handler)`?
<FromGitter> <asterite> you could have multiple hashes?
<FromGitter> <asterite> why do you need 1500 procs?
<hightower2> It's a program which reads the terminfo file and then configures itself to be able to output all the terminfo functions to the terminal. The real count is about 1/3rd of that number, and the other 2/3ds are aliases/alternative names
<hightower2> I could probably drop the amount of Procs to below 300 if I make it so that I don't create Procs for those which just return their input or a fixed value.
<hightower2> But I wanted to avoid having to check for type of value before determining whether I should use it directly or #call() it
<hightower2> Yeah Blacksmoke16 I thought about it... I'll try all the suggested/mentioned approaches combined - not using Procs when the value is just literal, and handling the rest with a wrapper type possibly
<FromGitter> <asterite> what are the different proc types that you have? are there many combinations?
<hightower2> Yes because they depend on the definitions from the terminfo file... large majority takes no input and returns Bool|Int|String. But those that do take input, the input can have any number of args
<hightower2> From 1 to 10
<hightower2> let me check something...
<FromGitter> <Blacksmoke16> could you group the procs based on the number of args they have
<hightower2> mm indeed
<hightower2> ok great, I'm gonna simplify considerably - not create procs when the value is literal, and then deal with the remaining ones afterwards
<hightower2> Thanks for the discussion/ideas
<FromGitter> <asterite> Could you generate the code at compile time, with a macro run?
<FromGitter> <asterite> Maybe a general overview of how you want users to use the library could help
return0e has joined #crystal-lang
<hightower2> Yeah no that would be easy... but a compiled program determines the file to read, and reads it, in runtime
<hightower2> And then "configures" itself accordingly. But this is fine, all the advice I got is more than enough
f1refly has quit [Quit: bye fags]
f1refly has joined #crystal-lang
ht_ has quit [Quit: ht_]
<hightower2> Hey what can I use for some generic alarm / timeout functionality? Like Ruby's Timeout thing
<FromGitter> <Daniel-Worrall> Vladfaust has a timer.cr shard you can use or copy
<hightower2> indeed, thanks
duane has quit [Ping timeout: 245 seconds]
sagax has quit [Ping timeout: 240 seconds]
<FromGitter> <manveru> does anyone know why this might happen?
<FromGitter> <manveru> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dd5cd179c9fca147c050f98]
<FromGitter> <manveru> i think it's from https://github.com/crystal-lang/crystal/blob/master/src/debug/elf.cr#L161 but since there's nothing else... i'm not sure why that might be needed for handling a http request
<FromGitter> <tenebrousedge> what's your code like?
<FromGitter> <manveru> it's a lucky app
<FromGitter> <tenebrousedge> ...okay. How about a code exerpt?
<FromGitter> <manveru> uhm, it's about 1500 lines atm... not sure which part :)
<FromGitter> <tenebrousedge> your backtrace should point you to where you're using HTTP::Handler, I would think
<FromGitter> <manveru> there is no backtrace...
<FromGitter> <manveru> i'm really mystified atm :|
<FromGitter> <manveru> here's a bit of strace output, but not sure that helps much
<FromGitter> <tenebrousedge> did you try adding `--error-trace` to your invocation?
<FromGitter> <manveru> yeah
<FromGitter> <tenebrousedge> is there a recent code change that triggered this? can you comment out lines of code until something works, or maybe use git-bisect?
<FromGitter> <manveru> i think i found the cause
<FromGitter> <manveru> this will be a fun hunt for the actual root cause though :)