<FromGitter>
<michalgritzbach> hi, i'm just starting with crystal and have a very beginner question – i've got type alias `alias FilterParams = {name: String?, status: Status?, gender: Gender?, species: String?, race: String?}`, but don't know how to use it
<FromGitter>
<michalgritzbach> when i do something like `Character::FilterParams{"name" => "Rick", "status" => :dead}`, I get `Error: no overload matches 'NamedTuple(name: String | Nil, status: Character::Status | Nil, gender: Character::Gender | Nil, species: String | Nil, race: String | Nil).new'`
<FromGitter>
<michalgritzbach> (i get the same error when even when i try the "full" version, with all the attributes)
<FromGitter>
<michalgritzbach> can you point me in the right direction please? O:)
<yxhuvud>
oprypin: *renaming* to .c is not sufficient in the general case. But creating a shim .c that include the .h which create functions that exposes the functions you need should work. The same strategy is needed for any functions defined in a .h with a static inline modifier.
<oprypin>
yxhuvud, i dont get it
<oprypin>
'static inline' - sure, but who would do such a thing
<yxhuvud>
a .h file may have arbitrary amounts of preprocessor macros, which simply won't work to link with.
<yxhuvud>
oprypin: The lib I write bindings against does such a thing :D
yxhuvud has quit [Remote host closed the connection]
yxhuvud has joined #crystal-lang
<FromGitter>
<dscottboggs_gitlab> oprypin, I linked the code in the original comment. It's the `webview/webview` library. ⏎ ⏎ yxhuvud, thanks for your advice ⏎ ⏎ The original header declares and documents the `extern` functions at the top of the file, so I'm gonna try cutting that out, putting it in a separate `.h` file, and renaming the (edited) original to `.cc`, then compile a `.o` with clang. ...
<FromGitter>
<dscottboggs_gitlab> oprypin, shit, hate when I do that
<FromGitter>
<dscottboggs_gitlab> hm, my shard actually takes a different approach, and I'm hoping to make it a little more ergonomic, in ways that wouldn't exactly work with how he's set it up.
<FromGitter>
<dscottboggs_gitlab> it's a tiny library so the bindings were easy.
postmodern has joined #crystal-lang
<FromGitter>
<grkek> Do you guys like Grip at all?
<FromGitter>
<grkek> I am having double thoughts about my work
<FromGitter>
<grkek> Good side and bad side, I sure know I might just go ahead and delete the github repo, github profile and then cry alone :D
<FromGitter>
<dscottboggs_gitlab> idk it's nice to have a simple router, it's not bad. I'm just not excited about web frameworks in Crystal because they're so damn common
<FromGitter>
<grkek> I made an UI framework too
<FromGitter>
<dscottboggs_gitlab> Oh??
<FromGitter>
<grkek> It just needs tests to get accepted to the crystal awesome list
<FromGitter>
<grkek> It is a bit clustered and needs refining but its not a bad idea
<FromGitter>
<grkek> > nice to have a simple router
<FromGitter>
<dscottboggs_gitlab> That's awesome! Just looking at the example here, and I wonder why you do `on_close = ->(window)` instead of `on_close do |window|`
<FromGitter>
<grkek> I really like it because of the simplicity
<FromGitter>
<grkek> ah that
<FromGitter>
<grkek> I don't really know how to use procs
<FromGitter>
<grkek> I hate procs
<FromGitter>
<dscottboggs_gitlab> oh
<FromGitter>
<grkek> I just couldn't use anything else
<FromGitter>
<grkek> so I do it in a way I know
<FromGitter>
<grkek> now on I know a better way to do it thanks to you
<FromGitter>
<grkek> He told me he liked the Kemal approach better and didn't understand why I did the oop approach for structure
<FromGitter>
<dscottboggs_gitlab> I really like athena. I see the appeal of lucky but I don't want to spend the time to learn it unless I have a reason to (i.e. for a job). Athena seemed like it was gonna be a lot, but it's actually really easy to just use the router component and then reach of other tools from it only when you need it, so the learning curve is more gradual instead of having to learn a bunch of stuff up front like
<FromGitter>
... with lucky or other big monolithic frameworks like rails
<FromGitter>
<dscottboggs_gitlab> so like...by being easy to get started with and *really* well documented, Athena kinda makes the whole class of router-only web frameworks obsolete in crystal, because you can just only use the router part of it and not have to learn the rest
<FromGitter>
<dscottboggs_gitlab> sorry :(
<FromGitter>
<grkek> Hm
<FromGitter>
<grkek> I wonder what
<FromGitter>
<grkek> You don't really need to learn anything to use grip
<FromGitter>
<dscottboggs_gitlab> well, you need to learn the DSL and how to define routes, which is the same as for any other web-router.
<FromGitter>
<dscottboggs_gitlab> I'm saying athena doesn't require you to learn *more* than that to get started, but it also comes with a slew of other useful tools
<FromGitter>
<dscottboggs_gitlab> and you never know what tools you're gonna need until you go solve something and realize there's already a tool to help with that.
<FromGitter>
<grkek> Oh that is so cool
<FromGitter>
<grkek> well I might actually try using athena
<FromGitter>
<dscottboggs_gitlab> nice 😀
<FromGitter>
<dscottboggs_gitlab> Re: IU layers ⏎ ⏎ I like it but I would do the naming a bit different.
<FromGitter>
<grkek> Likewhat
<FromGitter>
<dscottboggs_gitlab> instead of `do` and `undo` I would use...idk, I want to say `initialize` and `finalize` but those are already taken. `create` and `destroy`, perhaps?
<FromGitter>
<grkek> Sounds wise and interesting, I was just messing around with it and didn't even mean to do anything serious
<FromGitter>
<grkek> it works nicely
<FromGitter>
<grkek> I might continue my efforts with the UI framework
<FromGitter>
<grkek> I think I am done with Grip for a while now
<FromGitter>
<dscottboggs_gitlab> in general, though, I'm super excited to see a Crystal UI framework based on libui.
<FromGitter>
<dscottboggs_gitlab> > I think I am done with Grip for a while now ⏎ ⏎ You did just release 1.0, nothing wrong with calling it "done" haha
<FromGitter>
<grkek> Is there something wrong with actually doing that?
<FromGitter>
<grkek> I am new to this so I am not quite sure what I am doing via the versioning
<FromGitter>
<grkek> I just built the framework for myself and since others began to like it I thought it would be nice to put more effort in it
<FromGitter>
<dscottboggs_gitlab> no, not at all. Plenty of projects reach a point where the creator says "this has all the features I want, I'll just fix bugs and move on to other stuff"
<FromGitter>
<grkek> Sounds cute
<FromGitter>
<grkek> thank you :)
<FromGitter>
<grkek> Ill continue work on IU
<FromGitter>
<dscottboggs_gitlab> 😀
<FromGitter>
<grkek> Other UI frameworks piss me off
<FromGitter>
<dscottboggs_gitlab> oh?
<FromGitter>
<grkek> the GObject one has no documentation
<FromGitter>
<grkek> hedron has no support
<FromGitter>
<grkek> libui is literally bones
<FromGitter>
<dscottboggs_gitlab> well, it does if you know C ;) lol
<FromGitter>
<grkek> That is the problem here, I know C but I hate C at the same time
<FromGitter>
<dscottboggs_gitlab> yeah that was kinda what I was thinking tbh, I wish libui/hedron weas in a better state
<FromGitter>
<grkek> Basically I took hedron and slapped bunch of stuff on it
<FromGitter>
<dscottboggs_gitlab> > I hate C ⏎ ⏎ I can feel you there.
<FromGitter>
<grkek> It is a love hate relationship
<FromGitter>
<Blacksmoke16> @dscottboggs_gitlab ❤️ welcome to the dark side :S
<FromGitter>
<dscottboggs_gitlab> 😀
<FromGitter>
<grkek> @Blacksmoke16 I pissed you off with the comment on the Kemal issue didn't I
<FromGitter>
<Blacksmoke16> i'll just say going into another project and basically saying "you should try my project instead since it's better and has more features" probably isn't the most conscientious thing to do
<FromGitter>
<grkek> Sorry, I explained I am autistic and I can't help it
<FromGitter>
<dscottboggs_gitlab> oof, yeah, that's not very nice. But this seems like a discussion that could've been had privately....
<FromGitter>
<Blacksmoke16> meh, not really a big deal. Maybe a bit frowned upon but it could be worse :S
<FromGitter>
<dscottboggs_gitlab> does anybody know what this means? ⏎ ⏎ > `Program received and didn't handle signal IOT (6)`
<FromGitter>
<grkek> You sent a kill code of 6
<FromGitter>
<Blacksmoke16> esp since kemal dev isnt super active atm, having alternatives is a good thing. Just could have worded it a bit better 😉
<FromGitter>
<grkek> and the program doesn't know hot handle
<FromGitter>
<dscottboggs_gitlab> All I can find online is "you're doing something not thread safe, specifically in Crystal, not some other language"
<FromGitter>
<grkek> @Blacksmoke16 You are right I am not good with words:p
<FromGitter>
<dscottboggs_gitlab> yes, i know, but `man signal.h` doesn't document a signal IOT
<FromGitter>
<mwlang> I see Crystal has Colorize for colorizing outputs to terminal, but what about TTY Cursor functionality for clearing screens, moving cursor around, etc?
<FromGitter>
<dscottboggs_gitlab> @grkek I wouldn't worry too much about it. we all fuck up and step on each other's toes once in a while. Best thing to do is apologize and move on, and try not to do the samme thing again
<FromGitter>
<dscottboggs_gitlab> @mwlang there is a curses library but I'm not sure about ANSI codes
<FromGitter>
<Blacksmoke16> too bad you cant write minecrat mods in crystal :S
<FromGitter>
<dscottboggs_gitlab> you can just look up the code for what you want to do and print the control code to stdout
<FromGitter>
<mwlang> is that in a shard or a class of Crystals?
<FromGitter>
<dscottboggs_gitlab> it's a shard
<FromGitter>
<mwlang> ok thanks. I will hunt it down.
<FromGitter>
<Blacksmoke16> so yea, could show name/path/controller etc
<FromGitter>
<grkek> I used to do that with grip
<FromGitter>
<grkek> then thought it was stupid and did the now controller thing
<FromGitter>
<Blacksmoke16> main use for controllers in my case is DI
<FromGitter>
<grkek> I wish crystal had hot reloading
<FromGitter>
<Blacksmoke16> as well as the logical/organization grouping
<FromGitter>
<grkek> DI is nice I think you have a shard as I recall yes?
<FromGitter>
<Blacksmoke16> i do
<FromGitter>
<grkek> @Blacksmoke16 I fixed up the IU and fixed the CI
<FromGitter>
<grkek> added the compile test with github actions so it should comply with the awesome list
hightower2 has joined #crystal-lang
<FromGitter>
<Blacksmoke16> can you setup a periodic build as well? Like once a week or something
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo2 has joined #crystal-lang
<FromGitter>
<mwlang> trying to figure out how to parse a json from websocket where the stream name must be used to discriminate the payload. I found `JSON::Serializable.use_json_discriminator` but the examples I saw expected a fairly simple value.
<FromGitter>
<mwlang> I have to split the stream name into two parts to then determine payload.
<FromGitter>
<mwlang> for example, if it's a ticker stream, the name of the stream is `market_symbol@ticker` (i.e. `btcusdt@ticker`) and 'ticker' would be the discriminator
<FromGitter>
<mwlang> any thoughts on how I might approach this?
<FromGitter>
<mwlang> I thought about a converter that splits up that stream name into two string properties, but not sure how to do that, either. :-/
<FromGitter>
<j8r> the stream name?
<FromGitter>
<mwlang> I do know how to convert into a struct with two properties, though!
<FromGitter>
<mwlang> Argh! I remember this from last year now that I see your solution.
<FromGitter>
<j8r> honestly, the stdlib should only have had the pull parsers, IMO
<FromGitter>
<mwlang> I forgot about the need to implement a `#new`
<FromGitter>
<mwlang> but you're right. It's pretty aggravating and challenging to debug.
<FromGitter>
<j8r> Side note, Steam can be struct because immutable, and and in the initializer you can do `initialize(@stream : String, @symbol : String, @name : String, @data : Data)`
<oprypin>
I'm sure it will be a pleasure to follow with Crystal lang instead 😊
<FromGitter>
<dscottboggs_gitlab> it's not like you can finish it in the next 40 minutes, what a tease
<oprypin>
lol oh no i think the access is permanent
<FromGitter>
<dscottboggs_gitlab> > Unhandled exception: passing a closure to C is not allowed (Exception) ⏎ ⏎ 😡
<FromGitter>
<dscottboggs_gitlab> > The reason is that a Proc is internally represented as two void pointers, one having the function pointer and another the closure data. If just the function pointer is passed, the closure data will be missing at invocation time. ⏎ ⏎ Ah, that actually makes sense. I just wish there was some way around it... :(