yxhuvud has quit [Remote host closed the connection]
yxhuvud has joined #crystal-lang
notzmv has quit [Ping timeout: 240 seconds]
nopcOde has joined #crystal-lang
nopc0de has quit [Ping timeout: 244 seconds]
ur5us has quit [Ping timeout: 252 seconds]
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 244 seconds]
notzmv has joined #crystal-lang
Peter0x44 has joined #crystal-lang
<hightower3>
hmm, so I have a case where I need to write <header><body> into an IO. Length of (serialized) body must be specified in the header. But obviously I don't know the length of body until I serialize it, and it seems I need a temporary variable to store the serialized content, then update its length in the header, then write out both.
<hightower3>
Is there some clever trick maybe that I could use to avoid having to serialize to a temporary variable?
<hightower3>
well, I guess I could calculate the length in advance, without serializing it... that would be doable, although not very elegant unless I wrote a macro that produces the calc method automatically
Peter0x44 has quit [Ping timeout: 252 seconds]
Peter0x44 has joined #crystal-lang
<raz>
hightower3: is the IO seekable?
<hightower3>
no
<raz>
then you're out of luck i'm afraid :) (the only alternatives are to know the size beforehand or fixed framing)
<hightower3>
right, ok great, thanks for confirming
notzmv has quit [Ping timeout: 252 seconds]
notzmv has joined #crystal-lang
nopc0de_ has joined #crystal-lang
nopcOde has quit [Ping timeout: 244 seconds]
<riza>
is there a crystal shard wrapping libusb?
<riza>
or hidapi
sorcus has joined #crystal-lang
<SamantazFox_>
Mmmh, why does the formatter arbitrarily idents by 4 spaces on a wrapped if condition?
<straight-shoota>
It's a common style to indent wrapped expressions that way to visually separate them from the block body indent
<SamantazFox_>
the problem is that now, my closing parenthesis is at the level of the code below the `if`, not the `if` itself...
<FromGitter>
<Blacksmoke16> prob a bug
<straight-shoota>
I think that's intended
<straight-shoota>
the closing parenthesis has the same indent as the condition of the if
<straight-shoota>
s/of/after/
<SamantazFox_>
tbh, that's not ideal
<SamantazFox_>
makes code harder to read and confusing
<SamantazFox_>
(So is the removal of blank lines, btw)
<straight-shoota>
how is it harder to read? Or what would be easier?
<straight-shoota>
Blank lines should only be removed when non-essential. Can you show an example where it hinders readability?
ur5us has joined #crystal-lang
<FromGitter>
<beta-ziliani> `export LLVM_CONFIG=<path/to/your/llvm-config>` should do the trick
Guest70931 has joined #crystal-lang
mookie has quit [Ping timeout: 256 seconds]
<riza>
straight-shoota: I think that's a subjective analysis, but code readability in general is subjective. It's common in many languages to seperate functions into groups and to seperate the groups by 3 or 5 blank lines to indicate that the functions are logically grouped.
<raz>
crystal has keywords for grouping. class and module
<raz>
that's probably the only thing that golang every got right
<raz>
maybe a 3rd party formatter could exist with more flexibility. but i think there's value in having a canonical style that every CTO can use to choke out the endless vim vs emacs debates