jhass changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.1 | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <j8r> `typeof()`, `is_a?`
<FromGitter> <j8r> How can I represent a Float32 as a sequence of bytes?
<FromGitter> <j8r> I was thinking of like a one byte, to store the float position and the sign, then a regular UInt32
<FromGitter> <j8r> I can use the IEEE 754 format
<FromGitter> <j8r> Then, how to go back and forth? Float32 <=> IEEE 754
woodruffw has joined #crystal-lang
oddp has quit [Ping timeout: 260 seconds]
sgt_chuckles has quit [Remote host closed the connection]
<FromGitter> <dscottboggs_gitlab> I can do this I think
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 260 seconds]
<FromGitter> <s0kil> Since Crystal infers the types, could the docs generator add the return types of methods, etc ?
<FromGitter> <Blacksmoke16> possibly, but im not sure how useful that would be. As wouldnt it essentially be the same as "returns anything"
<FromGitter> <Blacksmoke16> as the return type could depend on the usages of that method
<FromGitter> <s0kil> Got it, makes sense
<FromGitter> <Blacksmoke16> on second thought idk, probably depends on the exact usage
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/9d6k
<FromGitter> <Blacksmoke16> like if that method was in a library without any actual usages, you wouldnt know
<FromGitter> <Blacksmoke16> but then every usage of it would add something to the union
<FromGitter> <Blacksmoke16> however thats prob not a super common use case id imagine
<FromGitter> <watzon> Yeah this is where being more explicit in your typing is helpful
<FromGitter> <Blacksmoke16> @j8r isnt that what https://crystal-lang.org/api/master/IO/ByteFormat.html is for?
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/9d6t
<FromGitter> <Blacksmoke16> also, whats up with lucky in https://github.com/the-benchmarker/web-frameworks ?
<FromGitter> <Blacksmoke16> its literally last
<FromGitter> <Blacksmoke16> that doesnt seem right
<FromGitter> <Blacksmoke16> given larvel is 2nd to last maybe just a bad run?
<FromGitter> <s0kil> "Results are not production-ready yet" ⏎ I have seen the results drastically change over time as they adopt different benchmarking techniques.
<FromGitter> <Blacksmoke16> seems to consistently in the bottom 5 tho
<FromGitter> <Blacksmoke16> like less than 2k
<FromGitter> <Blacksmoke16> worth some investigation to determine if its something with the benchmarking that could be improved, or a identify something that could be optimized
<FromGitter> <s0kil> Lucky is the last one, strange,
<FromGitter> <Blacksmoke16> yea, i would like to think it can do more than ~300/sec ha
<FromGitter> <s0kil> This is the last commit where lucky was #21, downhill from there https://github.com/the-benchmarker/web-frameworks/blob/7e6dce7586d1395d77a006efb5523599e5229869/README.md
<FromGitter> <s0kil> This is the last commit where lucky was number 21, downhill from there https://github.com/the-benchmarker/web-frameworks/blob/7e6dce7586d1395d77a006efb5523599e5229869/README.md
<oprypin> sgt_chuckles: just use CrSFML what's the problem
gangstacat has quit [Ping timeout: 272 seconds]
gangstacat has joined #crystal-lang
<jhass> s0kil: Blacksmoke16: the big issue with type inference for docs is that Crystal works by only instantiating called methods. What should it do for a method like def x(a); a.something; end;? The possible return types depend on what kind of types are passed and that's only known once you call the method with things and changes as you call it with different things
<raz> but doesn't the compiler have the knowledge anyway?
<jhass> I just explained why it does not
<raz> then how does it know and complain when i write that method and `a` doesn't have a something method?
<jhass> it does not until you actually invoke the method
<jhass> here it even could know that String doesn't have yeah_nope
<raz> yup, but for that case the docs could contain the types, right?
<jhass> but it never even checks until you call
<jhass> what types?
<raz> the argument and return types :)
<jhass> what would they be?
<raz> the ones that the method was called with and returned!
<jhass> but in a doc context most methods are never called
<raz> maybe docs are generated in the wrong context then ¯\_(ツ)_/¯
<jhass> and even if they would, it doesn't mean they're called with all possible or even realistic types
<jhass> what would be the right context?
<raz> that's true, but it would still be more convenient than having to manually annotate them
<raz> perhaps spec context
<jhass> this is not an argument of convenience but about possibility
<raz> that would also encourage people to improve their spec coverage
<jhass> and still it would be a heuristic and lead to misleading/wrong docs in some cases
<jhass> "Oh I cannot pass an X? Bummer" in fact you can, the specs just never idd
<raz> true, these rare cases could then be manually annotated
<raz> in the general case my specs exercise the methods in all ways they are intended to be used
<jhass> I disagree this is an awareness we can reasonable spread as the community grows
<raz> i dunno, just throwing ideas out. i would find it convenient not having to annotate all my methods to make the docs look right
<jhass> wrong docs are 1) an subtle error 2) more harmful than no docs
<raz> yup that part is true
<jhass> I'd argue the docs can look perfectly fine without types :)
<raz> they can, but i'm frequently annoyed when i can't click on the return type to see how to deal with it
<raz> but i'll concede that's a minor thing in the grand scheme of things
oddp has joined #crystal-lang
<FromGitter> <Daniel-Worrall> This Thread stuff on gitter confuses me
<jhass> yeah just avoid it, it doesn't work well with the bridge anyhow :P
<FromGitter> <Daniel-Worrall> I keep getting unread messages that won't clear cause they're part of threads
<jhass> come to IRC, problem solved :D
<FromGitter> <Daniel-Worrall> yeah, and more problems gained
<jhass> problems like not being forced to a single UI or not having enough tabs and hungry webapps in them open? :D
<raz> yes, come to the dark side! o/
<jhass> or white or purple or whatever you want your client background to be! xD
<FromGitter> <ImAHopelessDev_gitlab> hungry webapps? that's a nice euphemism for electron bloatware
<FromGitter> <j8r> @Blacksmoke16 seems to be, thanks! Remains to figure out how to decode in JS
<FromGitter> <j8r> I don't know what's the format
<FromGitter> <j8r> I can post this in the forum, will be better
<FromGitter> <Blacksmoke16> the format should be `BigEndian` or `LittleEndian`
<FromGitter> <Blacksmoke16> prob a node module out there somewhere to do this?
HumanGeek has quit [Remote host closed the connection]
HumanG33k has quit [Remote host closed the connection]
<FromGitter> <Blacksmoke16> > *<jhass>* problems like not being forced to a single UI or not having enough tabs and hungry webapps in them open? :⁠D ⏎ ⏎ Just download more RAM 😉
HumanGeek has joined #crystal-lang
HumanG33k has joined #crystal-lang
chachasmooth has quit [Ping timeout: 272 seconds]
<FromGitter> <j8r> Thats not really the format, but the endianess
<FromGitter> <j8r> By format I meant how it is represented with bytes
<FromGitter> <Blacksmoke16> ah, fair enough
chachasmooth has joined #crystal-lang
<FromGitter> <wyhaines> @j8r Also https://github.com/rochars/ieee754-buffer
<FromGitter> <wyhaines> Those should help with the JS side?
Human_G33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
Human_G33k has quit [Quit: Leaving]
HumanGeek has quit [Remote host closed the connection]
skrzyp1 has joined #crystal-lang
Vexatoast has joined #crystal-lang
skrzyp has quit [Ping timeout: 246 seconds]
Nekka has quit [Quit: zzz]
Vexatos has quit [Quit: ZNC Quit]
Nekka has joined #crystal-lang
_whitelogger has joined #crystal-lang
<sorcus> Blacksmoke16: Ah, thank you :-)
renich has joined #crystal-lang
<FromGitter> <j8r> @wyhaines thanks, hope that crystal encode to ieee754
<FromGitter> <j8r> I'm right that the most efficient way to transmit information between crystal server and browser, websocket with Bytes protocol?
<FromGitter> <j8r> *With reliably and low latency. There is also WebRTC, but not worth the complexity
renich has quit [Ping timeout: 260 seconds]
renich has joined #crystal-lang
f1reflyylmao has quit [Quit: bye fags]
f1refly has joined #crystal-lang
<FromGitter> <christopherzimmerman> Is it possible to pass a symbol into a function, and call it as an attribute on an object? Something like https://gist.github.com/christopherzimmerman/e26262ecd0c973cb637a1d73fe7235f5
<FromGitter> <christopherzimmerman> I feel like I'm missing something obvious
<FromGitter> <s0kil> > I'm right that the most efficient way to transmit information between crystal server and browser, websocket with Bytes protocol? ⏎ ⏎ On top of that `deflate-frame` WebSocket-Extension
<FromGitter> <Blacksmoke16> not sure i follow what the goal is there @christopherzimmerman
<FromGitter> <Blacksmoke16> `nt[{{key.symbolize}}]` would already return the value of the given key
<FromGitter> <christopherzimmerman> `nt` is the current named tuple, I want to call a function on that value, based on what is provided to `fns`
<FromGitter> <christopherzimmerman> So for the key `foo`, call `sum`, and for the key `bar`, call prod
<FromGitter> <Blacksmoke16> so like ruby's `send` method?
<FromGitter> <christopherzimmerman> I'm not too familiar with Ruby, but from what I can tell it's similar
<FromGitter> <Blacksmoke16> think you would have to change something tho, `U` is a type, not a value
<FromGitter> <Blacksmoke16> so you're iterating over `NamedTuple(foo: Symbol, bar: Symbol)`
<FromGitter> <Blacksmoke16> so would have to actually get the value from `fns` argument, but then you cant do what you want because crystal doesnt have send
<FromGitter> <eliasjpr> I have a private repo and shards install from within a docker container is not working as soon is public everything works. What I am doing wrong?
<FromGitter> <christopherzimmerman> Yea, I don't think there is a way to call a function by name, maybe if I converted everything to a macro? But that would be pretty messy
<FromGitter> <Blacksmoke16> not working how? says it doesnt exist?
<FromGitter> <Blacksmoke16> does the docker user have access to it?
<FromGitter> <christopherzimmerman> @Blacksmoke16 cleaner than I thought with a macro: https://gist.github.com/christopherzimmerman/e26262ecd0c973cb637a1d73fe7235f5
<FromGitter> <Blacksmoke16> 💭
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <watzon> Man tagged unions in Zig are a beautiful thing
duane has quit [Ping timeout: 246 seconds]
sagax has quit [Excess Flood]
DTZUZU has quit [Ping timeout: 265 seconds]
DTZUZU has joined #crystal-lang
renich has quit [Ping timeout: 256 seconds]
postmodern has joined #crystal-lang
f1refly has quit [Ping timeout: 244 seconds]
f1refly has joined #crystal-lang