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
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
<FromGitter> <fmatj> Is it intentional for the compiler to allow the implementation of abstract methods with a different type?
<FromGitter> <Blacksmoke16> pretty sure that would be a warning
<FromGitter> <Blacksmoke16> which will be an error in the future
<FromGitter> <fmatj> Sorry, I meant different return type.
<FromGitter> <Blacksmoke16> yes same what i said is still valid for that as well
<FromGitter> <Blacksmoke16> got an example?
<FromGitter> <fmatj> Like, `abstract def foo : Int` implemented by some `def foo : String` is allowed
<FromGitter> <Blacksmoke16> do you get a warning tho?
<FromGitter> <fmatj> No
<FromGitter> <fmatj> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f276031b6f7406a74040fef]
<FromGitter> <fmatj> Just wondering
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f27609da2be90499089f72c]
<FromGitter> <Blacksmoke16> what version you on?
<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]
alexherbo2 has quit [Ping timeout: 240 seconds]
<postmodern> while looking into how File.read is implemented, I found this weird line. https://github.com/crystal-lang/crystal/blob/5999ae29b/src/file.cr#L651
alexherbo2 has joined #crystal-lang
<FromGitter> <naqvis> comments clearly dictates the intention of that block of code
<FromGitter> <naqvis> why you think that is weird?
<FromGitter> <j8r> probably if it is 0, the read fails directly
<FromGitter> <j8r> and having a minimum size allows to expand the buffer?
<postmodern> also why pick 256? why not 1024 or 4096?
<FromGitter> <j8r> they would be too big
<FromGitter> <j8r> They are a lot of small size files in /proc, that's likely the main use case for this logic
<FromGitter> <benphelps> can I define a custom union type ?
<FromGitter> <benphelps> PheltNumber = PheltObject::Integer | PheltObject::Float
<FromGitter> <benphelps> alias worked fine for that
<FromGitter> <benphelps> no idea if thats the right way to do it but I'm gonna run with it
postmodern has quit [Quit: Leaving]
<jhass> yes, that's the right way
sorcus has joined #crystal-lang
sagax has joined #crystal-lang
<FromGitter> <j8r> the encoding is not stored in the `String`?
<FromGitter> <j8r> I can assume that if there is a `String`, it is encoded in `UTF-8`
<jhass> yes
<jhass> used to be validated even, unfortunately that was removed to accomodiate "binary data"
morantron has joined #crystal-lang
<Rounin> I suppose binary "strings" might be an advantage for filenames
<Rounin> There's always one file that was incorrectly encoded and converted across 90 different encodings
zorp has joined #crystal-lang
<FromGitter> <j8r> Won't it make snese to have 2 strings then?
<FromGitter> <j8r> `EncodedString < String`?
duane has joined #crystal-lang
<Rounin> Seems sensible, j8r... Or one could have an encoding called "AnythingGoes"
<FromGitter> <sclee15> Can Crystal compile an arm binary?
<FromGitter> <Blacksmoke16> i think support for it has gotten a lot better recently
<FromGitter> <Blacksmoke16> but im no expert on it
<FromGitter> <j8r> there is a CI for aarch64
<FromGitter> <j8r> But armhf is still not well supported
<FromGitter> <j8r> (but may work)
<FromGitter> <Blacksmoke16> @bcardiff should the abstract def check warning be made an error before `1.0.0`?
<FromGitter> <Blacksmoke16> not sure if that was done already
<FromGitter> <bcardiff> @Blacksmoke16 the abstract check emit errors already in 0.35. Do you see a different behavior?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f2822fc61a8316846352ef1]
<FromGitter> <Blacksmoke16> is what i get
<FromGitter> <bcardiff> oh, the return type check of abstract method. Yeah, it would make sense to have that in 1.0 as errors I think
<FromGitter> <Blacksmoke16> mhm, want me to make an issue?
<FromGitter> <bcardiff> Please :-) and we could also remove the skip_abstract_def_check flag. it's been a while
<FromGitter> <Blacksmoke16> 👍
<livcd> asterite was again having a moment reg. autocompletion :D
Dreamer3 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 246 seconds]
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 264 seconds]
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 246 seconds]
alexherbo2 has joined #crystal-lang
<FromGitter> <Sija> https://carc.in/#/r/9hqa -> is this a bug? /cc @asterite
<FromGitter> <Sija> `typeof(v)` should be a `Symbol` not `Symbol?`, no?
<FromGitter> <Blacksmoke16> https://carc.in/#/r/9hqo
<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
<FromGitter> <Blacksmoke16> looks like you can just use a crystal enum for both
<postmodern> right, but C bindings enums are slightly different than regular crystal enums? same with C binding structs vs. crystal structs.
<FromGitter> <Blacksmoke16> :shrug: based on that page id vote it would just work