<FromGitter>
<fmatj> Ugh, you're right. I had an older binary in my PATH...
<FromGitter>
<fmatj> Nevermind, thanks :P
<FromGitter>
<Blacksmoke16> np
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 272 seconds]
chachasmooth has quit [Ping timeout: 246 seconds]
chachasmooth has joined #crystal-lang
uni has quit [Ping timeout: 265 seconds]
zorp has quit [Ping timeout: 260 seconds]
postmodern has joined #crystal-lang
sagax has quit [Excess Flood]
postmodern has quit [Remote host closed the connection]
postmodern has joined #crystal-lang
<postmodern>
how do you read binary data from a file? I tried File.read(path,"US-ASCII") but getting Invalid multi-byte sequence.
ua has joined #crystal-lang
<postmodern>
also how does crystal's YAML implementation handle `:foo` symbols if all symbols have to be defined by the program?
oprypin has quit [Ping timeout: 260 seconds]
oprypin has joined #crystal-lang
<postmodern>
can you use String in C bindings, such that a NULL char * get's automatically mapped to nil?
sagax has joined #crystal-lang
alexherbo2 has joined #crystal-lang
HumanG33k has quit [Ping timeout: 256 seconds]
HumanG33k has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 264 seconds]
<jhass>
postmodern: re string, no, but null pointers are falsey so it's just (ptr && String.new(ptr)
<jhass>
postmodern: re yaml, no idea, just try it out? If I had to make a bet, I'd go for ":foo"
<jhass>
postmodern: I think there's no shorthand, you probably should be using File.open with a block, then IO#read on the handle with a slice of your buffer size. If you need the entire file in a single buffer for some strange reason, the fastest way is probably to get an IO::Memory and use IO.copy, then IO::Memory#to_slice
sorcus has quit [Ping timeout: 272 seconds]
alexherbo2 has joined #crystal-lang
sagax has quit [Remote host closed the connection]
<FromGitter>
<Blacksmoke16> but yea, i guess compiler still thinks there is a case where `v` wont be initialized
<FromGitter>
<Sija> nice workaround, it still seems like a bug though
<FromGitter>
<j8r> I don't think it is a bug
<FromGitter>
<j8r> this will prevent to use symbols inside
<FromGitter>
<j8r> nvm
<FromGitter>
<j8r> There is implicitly a `v = nil` on top
<FromGitter>
<j8r> yeah, implicit nils...
<FromGitter>
<j8r> For me, it would be logical to have a compile time error
<FromGitter>
<j8r> or maybe not, because at then end `case` is just `if/elsif`s...
<FromGitter>
<j8r> Don't know how the compiler can figure out how `v` cannot be nil, would be hard (I guess?). ⏎ It will have to traverse each condition branch :/
<FromGitter>
<Blacksmoke16> yea but this is exhaustive case, so id think the compiler would be know one of those will be hit
<FromGitter>
<Blacksmoke16> would have to like see if its being assigned in each one
<FromGitter>
<Blacksmoke16> prob easier to just use my workaround :S
<FromGitter>
<j8r> sure, that's not even a workaround but the way to do usually!
<FromGitter>
<Blacksmoke16> @Sija maybe add a test case to assert its nilable if you assign it one `in` but not another
<FromGitter>
<j8r> the fix sounds too simple...
morantron has quit [Ping timeout: 260 seconds]
<FromGitter>
<j8r> tested locally, seems to work
<FromGitter>
<j8r> there is already this logic for if/elsif, interestingly
<FromGitter>
<j8r> ha that comes from Ruby, quite ambiguous this name
<FromGitter>
<wyhaines> @j8r It comes directly from the underlying C implementation: ⏎ ⏎ https://www.tutorialspoint.com/ftell-in-c#:~:text=In%20C%20language%2C%20ftell(),the%20end%20of%20the%20file.
HumanG33k has quit [Quit: Leaving]
<FromGitter>
<benphelps> the type system is impressive
<FromGitter>
<Blacksmoke16> 👍
Dreamer3 has quit [Quit: Leaving...]
ua is now known as uni
postmodern has joined #crystal-lang
<postmodern>
i don't suppose there's an easy way to sesrialize/deserialize C enums into/from YAML?
<FromGitter>
<Blacksmoke16> cant use a standard `enum`?
<FromGitter>
<Blacksmoke16> could define a constructor to go from C to crystal enum member then serializer that
<postmodern>
Blacksmoke16, the enum comes from the C bindings and is returned by the C callbacks
<postmodern>
suppose i could use a macro to re-create the C bindings enum as a Crystal enum