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
deavmi has quit [Ping timeout: 256 seconds]
deavmi has joined #crystal-lang
postmodern has joined #crystal-lang
oddp has quit [Ping timeout: 256 seconds]
_whitelogger has joined #crystal-lang
<FromGitter> <mwlang> hmmm...any significant changes to `JSON::PullParser` and `JSON::Serializable`
<FromGitter> <Blacksmoke16> some stuff related to enums iirc
<FromGitter> <Blacksmoke16> why whats the error?
<FromGitter> <mwlang> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f2e00699231d665df62bbd6]
<FromGitter> <Blacksmoke16> sure the input just isnt an array when it should be an obj?
<FromGitter> <Blacksmoke16> `pull.kind == :begin_array`
<FromGitter> <Blacksmoke16> `pull.kind.begin_array?`
<FromGitter> <Blacksmoke16> try that
<FromGitter> <mwlang> ok
<FromGitter> <mwlang> that solved it.
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <mwlang> now to fix the other 6 or so. :-D
alexherbo2 has quit [Ping timeout: 240 seconds]
<postmodern> is there something like getter! but lets you specify the error class to raise-on-nil?
<postmodern> trying to define a getter that returns Foo or @[Raises(Unsupported)], but the compiler keeps saying the return signature is Nil | Foo
<FromGitter> <Blacksmoke16> define the getter yourself
<FromGitter> <Blacksmoke16> ```def foo ⏎ @foo || raise Unsupported.new ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5f2e0a4879da21426f1edff3]
<postmodern> trying to but getting that type signature error
<FromGitter> <Blacksmoke16> can you make an example?
<postmodern> ah that did the trick
<FromGitter> <Blacksmoke16> 👍
<postmodern> i was trying to do unless @foo ... raise ... end ... return @foo
<FromGitter> <Blacksmoke16> yea that wouldnt help
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 256 seconds]
duane has quit [Remote host closed the connection]
<FromGitter> <mwlang> If I set cossack to ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f2e0dcb88719865d948562f]
<FromGitter> <Blacksmoke16> Try adding like --ignore-crystal-version
<FromGitter> <mwlang> The weird thing is that the output did show that it changed. before the update, `shards update` showed: `Using cossack (0.1.4 at 0fba91e)` and while running the `shards update cossack` command, it output `Using cossack (0.1.5 at dc6dc41)`
<FromGitter> <Blacksmoke16> Or something like that
<FromGitter> <Blacksmoke16> Or maybe try deleting lib and shard.lock
<FromGitter> <mwlang> whacked. This time it outputs `Installing cossack (0.1.5 at dc6dc41)`
<FromGitter> <Blacksmoke16> Nice
<FromGitter> <Blacksmoke16> oh i read that as `worked`
Human_G33k has quit [Ping timeout: 264 seconds]
gangstacat has quit [Ping timeout: 272 seconds]
Human_G33k has joined #crystal-lang
<FromGitter> <mwlang> It did work!
<FromGitter> <mwlang> without the --ignore-crystal-version flag, it'll say "Using" instead of "Installing" on that 0.1.5 at dc6dc41 commit SHA
<FromGitter> <mwlang> so probably a bug in shards
DTZUZU has quit [Quit: WeeChat 2.8]
<FromGitter> <mwlang> I'm guessing HTTP::WebSocket has changed significantly as well... ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5f2e17fb88719865d9486d7e]
gangstacat has joined #crystal-lang
<FromGitter> <mwlang> yup, CloseCode and String are returned instead of just a String
<FromGitter> <mwlang> Has the size of an integer for the JSON any class changed? For value 5292811062 I get ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f2e1aafe20413052e72d775]
<FromGitter> <mwlang> nevermind -- just realized I truly am busting 32-bit limit
_whitelogger has joined #crystal-lang
Human_G33k has quit [Ping timeout: 240 seconds]
<postmodern> so @[Deprecaated] only shows up in the documentation? There's no way to warn at compile or runtime time?
Human_G33k has joined #crystal-lang
<postmodern> hmm suppose i could use a macro to somehow check for @[Deprecated]. I'm trying to tag a C enum element with @[Deprecated] and filter it out of other macro code that loops over the enum
_whitelogger has joined #crystal-lang
Human_G33k has quit [Ping timeout: 264 seconds]
<postmodern> hair splitting question, is Pointer(T)#address the address _of_ the pointer or the address the pointer is pointing _to_
<postmodern> nm appears to be the pointer's "to" address
Human_G33k has joined #crystal-lang
<postmodern> would crystal's GC possibly fight with LibC.mmap'd memory? I have gotten the point where i am getting V4L2 to read frames into mmap Bytes slices, but when I print them out it prints "Bytes[" then Invalid memory access at 0xffffffffffffffff
<postmodern> making progress one error at a time :)
<FromGitter> <benphelps> is there a way to specify types on hash keys ?
<FromGitter> <benphelps> well, types on hash key/value pairs i guess
<FromGitter> <benphelps> `{ :input => "1+1", :expected => 2 }` ⏎ where I define :input has a string value and :expected has an Int32 value
_whitelogger has joined #crystal-lang
Human_G33k has quit [Ping timeout: 260 seconds]
Human_G33k has joined #crystal-lang
alexherbo2 has joined #crystal-lang
Human_G33k has quit [Ping timeout: 240 seconds]
<postmodern> benphelps, { :input => "...", :expected => 2} of Symbol => (String | Int32)
<postmodern> benphelps, but you probably want a NamedTuple
Human_G33k has joined #crystal-lang
<postmodern> benphelps, NamedTuple(input: String, expected: Int32).new(input: "1+1", expected: 2)
<postmodern> because Hashes can contain any number of pairs
oddp has joined #crystal-lang
Human_G33k has quit [Ping timeout: 264 seconds]
Human_G33k has joined #crystal-lang
<postmodern> is there a way to define a method overload where one of the arguments is a literal value, like from an enum?
<postmodern> hmm found my probllem with mmap. I'm testing for pointer.address == LibC::MAP_FAILED, but it's not catching the 0xffffffffffffffff address
<postmodern> note that MAP_FAILED = Pointer(Void).new(-1)
<postmodern> ah needed pointer == LibC::MAP_FAILED
<postmodern> one step forward, two steps back. the v4l2 api is "interestingly" design
<yxhuvud> What is v4l2?
<yxhuvud> postmodern, benphelps: personally I'd use a record in that situation, record SomeNiceName, input : String, expected : Int32.
<yxhuvud> That also allows for methods on it.
<FromGitter> <Blacksmoke16> ^
<postmodern> yxhuvud, Video 4 Linux (2) API. It provides direct kernel access to webcams, as well as a lesser used deep and big API for TV and Digital SDR cards
<postmodern> yxhuvud, https://gist.github.com/maxlapshin/1253534 the API allows for three separate ways of reading data, each with slight variations with how you handle the data you store on your side and what the kernel gives back to you via the ioctl()'ed structs
<yxhuvud> Ah, I see.
<postmodern> so far i have all of the C stuff mapped in, now just writing the classes that wrap around all of that and define the behavior
<FromGitter> <Blacksmoke16> Best bet would be a method restricted to the enum then use a case in
<postmodern> Blacksmoke16, can enums be restricted by the argument signature, or do you have to do that in code with case/when/raise?
<yxhuvud> You can't restrict by value, only by type, if that is what you are asking.
<postmodern> ah dang
<postmodern> was hoping to do something like #allocate(memory : Memory::USER_PTR, length : UInt32) and #allocate(memory : Memory::MMAP) or such
<postmodern> that would save me from having separate #mmap() and #malloc(length : UInt32) methods
<yxhuvud> that particular example have different signature though, so that would work even if the type system wouldn't enforce it being correct.
<yxhuvud> so correct parameters would have to be verified in the method body. :/
<postmodern> ah because the enum values are instances of the same enum. hmm
<yxhuvud> or well, you'd have to have memory as a Memory, but it would dispatch differently due to the length parameter being there or not
Human_G33k has quit [Remote host closed the connection]
Human_G33k has joined #crystal-lang
<FromGitter> <Blacksmoke16> Yea you can't, hence my case in suggestion
<FromGitter> <benphelps> @postmodern, yep named tuple is what I wanted, thank you
<FromGitter> <Blacksmoke16> a struct would most likely be better tho
<FromGitter> <benphelps> i don't know if it needs to be on the stack though since it's just tests
<FromGitter> <Blacksmoke16> named tuples are as well
<FromGitter> <benphelps> oh
<FromGitter> <Blacksmoke16> majority of the time you should use a struct versus a named tuple
oddp has quit [Quit: quit]
DTZUZU has joined #crystal-lang
<FromGitter> <j8r> Yeah a struct is usually better
<FromGitter> <j8r> You can also add API docs about each getter, or property. In your case, what is `expected`and `input`. ⏎ Plus, methods can be added
<FromGitter> <j8r> The main thing practical about NamedTuple is splat it to a method as `**kwarg`, and eventually iterating over each key
<FromGitter> <j8r> And also for tests
Human_G33k has quit [Remote host closed the connection]
Human_G33k has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 244 seconds]
f1refly has joined #crystal-lang
postmodern has quit [Quit: Leaving]
HumanGeek has joined #crystal-lang
Human_G33k has quit [Ping timeout: 240 seconds]
<FromGitter> <Blacksmoke16> splat the args into a struct 😉
oddp has joined #crystal-lang