ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.33.0 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
ur5us has joined #crystal-lang
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
postmodern has joined #crystal-lang
<postmodern> what is the preferred/safe way of passing strings, bytes, arrays of bytes, to a C function that accepts UInt8*? #to_slice and just hope GC doesn't free the passed in data? Does one make a copy of the data?
<postmodern> nm i'll just dup/clone and store as ivars
<postmodern> what's this about "can't use Int as a block return type yet, use a more specific type"?
<FromGitter> <Blacksmoke16> yea...
<FromGitter> <Blacksmoke16> would have to use like `Int32` or whatever
<FromGitter> <Blacksmoke16> or can use https://crystal-lang.org/api/master/Int/Primitive.html
<FromGitter> <Blacksmoke16> to represent a union of all possible `Int` types, which is essentially the same thing
<postmodern> i've noticed by default the compiler aggressively omits code that isn't called. this can lead to bugs getting past me and the compiler. i suppose i should start writing tests at this point, but is there a way to tell the compiler to type check _everything_?
<FromGitter> <Blacksmoke16> Use it at least once?
<FromGitter> <Blacksmoke16> What's the use case for wanting dead code in your binary?
<postmodern> is there something like the delegate macro, but maps to a different method on the ivar?
<FromGitter> <Blacksmoke16> Could just define it yourself, that's all delegate does
<postmodern> true. how does documentation work with macros? will the doc-generator associate an above block of doc comments with the macro?
<FromGitter> <Blacksmoke16> It would be with what ever the macro generates
<FromGitter> <Blacksmoke16> Unless of course the doc comment is above the macro definition
<postmodern> nice. that always discouraged me about ruby's meta-programming vs doc generation
<FromGitter> <Blacksmoke16> Ofc it only works if what you want the docs on is at the"top" of the macro
<FromGitter> <Blacksmoke16> Isn't a built in way to add separate docs to each method if a macro generates more than one
<postmodern> so how do you wrap a closure in a proc, and pass that to C land? i don't care about the pointer argument that C passes back to the Proc, since it's the same as the struct i'm wrapping. Just want to pass in a (self) -> Int32 closure.
<FromGitter> <Blacksmoke16> wouldnt it just be a proc?
ur5us has quit [Ping timeout: 240 seconds]
DTZUZU has quit [Ping timeout: 268 seconds]
DTZUZU has joined #crystal-lang
postmodern has quit [Quit: Leaving]
_ht has joined #crystal-lang
_ht has quit [Remote host closed the connection]
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 240 seconds]
<repo> hi! i get a invalid memory access error when i build and run the following in the official alpine image and link statically: https://p.jokke.space/eLD/crystal
<repo> the error is thrown before i even get into File.open
<repo> but if i don't pass an argument, usage is shown correctly
<repo> so i doubt it is related to the required file
Nicolab has joined #crystal-lang
<repo> this happens both on 0.32.1 and 0.33.0
<repo> the error is thrown twice.
<repo> maybe 500ms apart
<repo> never mind, it was caused by the Process.run
ur5us has joined #crystal-lang
postmodern has joined #crystal-lang
<postmodern> what's the real difference between procs and closures? anytime my proc references variables outside it's scope, i get an exception about passing a closure to a C function.
<repo> yes, that's the difference
<repo> :)
<repo> when a proc accesses variables in the scope it was defined in, that's a closure
<repo> postmodern: it makes sense that you can't pass those to a c function
<postmodern> odd seems a bit too implicit. was expecting like different syntax or a different type
<repo> i guess, but i can understand why it hasn't been made explicit. Inside of crystal you can pass both around
<repo> about my invalid memory access problem: i've narrowed it down to a simple from_yaml call
<repo> this is the structure i'm trying to parse: https://p.jokke.space/Oq1/
<repo> any ideas why this might fail (only in alpine)
<repo> works fine on arch linux
<FromGitter> <alex-lairan> Hello, guys! ⏎ ⏎ I'm trying to import a C lib to crystal but it ain't work. ⏎ ⏎ Where do I have failed? ... [https://gitter.im/crystal-lang/crystal?at=5e4a64f0b401eb68a5816058]
ur5us has quit [Ping timeout: 240 seconds]
<postmodern> alex-lairam, i think you might need to export LD_LIBRARY_PATH=/usr/local/lib
<FromGitter> <alex-lairan> Yes, that's it thanks
<FromGitter> <yxhuvud> procs referencing variables in the creating scope is very fragile also in pure crystal. It is *very* easy to get crashes due to the variable not being on the stack anymore.
Nicolab has quit [Quit: Leaving.]
<postmodern> yxhuvud, isn't that why typically you'd save them into ivars or class vars?
<postmodern> so what are the restrictions for using _ in case/when statements? seems i cannot use _ on arrays?
Human_G33k has quit [Ping timeout: 240 seconds]
masterdonx2 has quit [Ping timeout: 272 seconds]
MasterdonX has joined #crystal-lang
Human_G33k has joined #crystal-lang
<postmodern> also how does one use vim-crystal with vim8's packadd? doesn't seem to provide the opt/ and start/ directories.
sorcus has quit [Ping timeout: 272 seconds]
sorcus has joined #crystal-lang
<FromGitter> <yxhuvud> postmodern: Yes, storing stuff on the heap is safe. But I've seen it happen a couple of times that they refer to a local and then don't understand why things break.
<FromGitter> <yxhuvud> Hmm, can you show an example of it not working?
<postmodern> yxhuvud, which version would you like? i've been trying various approaches. capturing/wrapping the block, using Box, etc.
<postmodern> think i may be being bit by local variable name shadowing
<FromGitter> <yxhuvud> No, I meant the case statement. I really don't have any experience with callbacks except reading the gitbook page on it
<postmodern> yxhuvud, https://carc.in/#/r/8kp1
postmodern has quit [Read error: Connection reset by peer]
postmodern has joined #crystal-lang
<FromGitter> <yxhuvud> `_`-syntax only work with tuples, AFAIK.
<FromGitter> <yxhuvud> .. but it still requires the tuple to be defined in the actual case-statement. That part might want a bug report.
<postmodern> yeah seems overly specific/niche. i prefer semantic rules to work everywhere, not just in one specific use case
<FromGitter> <yxhuvud> Yes. Differences between what is supported for Arrays and Tuples are *probably* intentional though.
sorcus has quit [Ping timeout: 240 seconds]
sorcus has joined #crystal-lang
<FromGitter> <alex-lairan> I come back with my Interop. ⏎ ⏎ I have ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=5e4a97a1292ff243d3d191ed]
<FromGitter> <alex-lairan> (Also with `Foo*` on the crystal part)
<FromGitter> <yxhuvud> don't you need to mark init_foo as extern as well, to mark it for being visible outside the file?
<FromGitter> <alex-lairan> ` extern Foo* init_foo();` ?
<FromGitter> <alex-lairan> I think the error comes from the struct I think.
<FromGitter> <alex-lairan> I have retry with ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ With a pointer, it passes correctly [https://gitter.im/crystal-lang/crystal?at=5e4a999e9d4c83598b96a0b5]
<FromGitter> <alex-lairan> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e4a99ad0d257250fdf0b761]
<FromGitter> <alex-lairan> The `init_foo() : Foo*` cause exactly the same error
<postmodern> alex-lairan, you need to both mark init_foo() as extern, and have your crystal function return Foo*, not plain Foo.
<FromGitter> <alex-lairan> Already done for Foo on crystal
<FromGitter> <alex-lairan> Tried to change the code from C++ to C, no changes
<FromGitter> <alex-lairan> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e4aa18eae97f1297580d629]
<FromGitter> <yxhuvud> Try to add `extern` to your function modifiers
<FromGitter> <alex-lairan> witch one? C or Crystal ?
<FromGitter> <yxhuvud> C
<FromGitter> <alex-lairan> ```extern struct Foo* init_foo(); ⏎ extern int* give_42();``` ⏎ ⏎ this changes nothing :( [https://gitter.im/crystal-lang/crystal?at=5e4aa2b6292ff243d3d1b1d8]
<FromGitter> <yxhuvud> Well, it works for me.
<FromGitter> <alex-lairan> I have created https://forum.crystal-lang.org/t/c-interop-pointer-c/1727
<FromGitter> <alex-lairan> It works for you? What the code? ^^
<FromGitter> <yxhuvud> works for my shim files in https://github.com/yxhuvud/ior . *shrugs*
<FromGitter> <alex-lairan> My lib build had errors, it works now !
<FromGitter> <alex-lairan> Thanks for your help @yxhuvud
<FromGitter> <alex-lairan> Any ideas how to transform pointer to array ?
sorcus has quit [Ping timeout: 246 seconds]
sorcus has joined #crystal-lang
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Array.html#build(capacity:Int,&):self-class-method
<FromGitter> <Blacksmoke16> Or something along those lines?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Array.html#new(size:Int,&block:Int32-%3ET)-class-method or that one
Human_G33k has quit [Read error: Connection reset by peer]
HumanG33k has joined #crystal-lang
<FromGitter> <alex-lairan> Thx @Blacksmoke16 I use the ⏎ ⏎ ```result = Array(Int32).new(bar.size) do |i| ⏎ bar.array[i] ⏎ end``` ⏎ ⏎ I realy like it [https://gitter.im/crystal-lang/crystal?at=5e4aad3ab401eb68a5821713]
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <alex-lairan> Let's begin my real lib :D
return0__ has joined #crystal-lang
return0e has quit [Ping timeout: 248 seconds]
<FromGitter> <j8r> What is the proper way to transform a `HTTP::Request#body : IO` to a `String`?
<FromGitter> <Blacksmoke16> `.gets_to_end`?
<FromGitter> <j8r> ha ok, I was thinking to create a buffer my self
<FromGitter> <Blacksmoke16> yea its just an `IO`, so normal `IO` stuff applies
<FromGitter> <j8r> I'm now struggling with the issue we talked before
<FromGitter> <Blacksmoke16> which one? abstract parent type or?
<FromGitter> <j8r> with `Proc(T, U)`, we can't define T
<FromGitter> <Blacksmoke16> right so instead of doing `Route(T, U)` you'll have to do `Route(Proc(T, U))`
<FromGitter> <Blacksmoke16> and pass the proc type itself as a generic
<FromGitter> <Blacksmoke16> are you not using macros to build the nodes? as actually that workaround is only needed if you're using splat generics
dwdv has joined #crystal-lang
<FromGitter> <j8r> ha ok
<FromGitter> <j8r> what I was doing is `post return_type: SomeResponseBodyClass`
<FromGitter> <Blacksmoke16> ah, hm
<FromGitter> <Blacksmoke16> might be a bit trickier then
<FromGitter> <j8r> I may have to create an intermediary generic to declare T
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <j8r> I got it, I think it just have to be mandatory
postmodern has quit [Quit: Leaving]
<FromGitter> <j8r> It doesn't seem to work when I set a default class
<FromGitter> <Blacksmoke16> gotcha
<FromGitter> <j8r> I'm creating base controllers. One for HTTP and the other for WebSocket
<FromGitter> <j8r> and custom ones can be used too
<FromGitter> <j8r> I make the request_body mandatory, it can't harm
<FromGitter> <j8r> *type
<FromGitter> <j8r> I works, nice! The work around I done to restrict `T forall T` is to pass `T` to another method, which has type restrictions
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <Blacksmoke16> that'll work i guess
<FromGitter> <jwoertink> I'm using the docker container `FROM crystallang/crystal:0.33.0` and trying to install postgres-11 on it
<FromGitter> <jwoertink> It keeps complaining about `postgresql-11 : Depends: libicu55 (>= 55.1-1~) but it is not installable`, but crystal 0.32.0 works fine
<FromGitter> <jwoertink> looking around it looks like maybe some llvm type deal? I'm not totally sure
<FromGitter> <jwoertink> Has anyone else run in to this?
<FromGitter> <tenebrousedge> why not use a separate image?
<FromGitter> <j8r> `apt update`?
<FromGitter> <tenebrousedge> imo this is what docker-compose is for
<FromGitter> <jwoertink> This is on a new fresh container, but it does run apt update after setting sources
<FromGitter> <jwoertink> I'm not great at using Docker. So maybe there's a better way to do this
<FromGitter> <jwoertink> I do use docker-compose to install postgres server
<FromGitter> <jwoertink> but I need my container to have postgres client too
<FromGitter> <tenebrousedge> ahhhhhh gotcha
<FromGitter> <tenebrousedge> can you paste your dockerfile?
<FromGitter> <jwoertink> I haven't pushed an update yet, but the only difference is the crystal version
<FromGitter> <jwoertink> and the compose file
_ht has joined #crystal-lang
<FromGitter> <j8r> @jwoertink it is mentioned Xenial
<FromGitter> <j8r> the image is Bionic
<FromGitter> <j8r> try replacing `xenial-pgdg` by `bionic-pgdg`
<FromGitter> <jwoertink> oh?
<FromGitter> <jwoertink> Is Bionic a new ubuntu version?
<FromGitter> <j8r> in fact, `. /etc/lsb-release; echo $DISTRIB_CODENAME`
<FromGitter> <j8r> yes the image has been updated
<FromGitter> <jwoertink> gotcha
<FromGitter> <jwoertink> let me try that
<FromGitter> <tenebrousedge> can confirm, this works
<FromGitter> <j8r> Xenial is 16.04, Bionic 18.04
<FromGitter> <watzon> Interesting find. This works: https://carc.in/#/r/8krw, but this doesn't: https://carc.in/#/r/8krv. It would be nice if symbol autocasting worked in arrays.
<FromGitter> <j8r> I think it can't happen
<FromGitter> <j8r> and it is nice IMO
<FromGitter> <jwoertink> oh sweet. I think it's working. It got past that one step.
<FromGitter> <jwoertink> Awesome. Thanks!
<FromGitter> <jwoertink> yup. It's running.
beepdog has quit [Ping timeout: 240 seconds]
juanfra_ has quit [Ping timeout: 260 seconds]
fifr[m] has quit [Ping timeout: 248 seconds]
erdnaxeli has quit [Ping timeout: 256 seconds]
olbat[m] has quit [Ping timeout: 240 seconds]
<FromGitter> <j8r> @Blacksmoke16 I've made the Router indendent of the abstactions, so others like Athena may use it and have nearly free swagger docs support (or easy to do)
<FromGitter> <j8r> Even if Radix is used anyway, it the router could only be used for doc generation
<FromGitter> <asterite> @jwoertink is your app with file descriptor leaks creating websockets?
<FromGitter> <jwoertink> nope
<FromGitter> <asterite> oh... maybe that was it :-)
olbat[m] has joined #crystal-lang
<FromGitter> <jwoertink> just postgres / http
<FromGitter> <jwoertink> app just went down again. It's pretty easy to see when it does
<FromGitter> <jwoertink> We're still trying to come up with a smaller example of how to replicate it, but it's a little tough 😅
<FromGitter> <Blacksmoke16> @j8r how would that work? i assume the user would have to basically resetup their routes for it to know how to generate the docs?
beepdog has joined #crystal-lang
erdnaxeli has joined #crystal-lang
juanfra_ has joined #crystal-lang
<FromGitter> <j8r> Instead of adding to Radix, the web framework can add routes to the Router
<FromGitter> <j8r> It takes an `Array(String | PathParameter)` – that's it
<FromGitter> <Blacksmoke16> @watzon they're there, if you look at the config examples is a `formatter: Log::DefaultFormatter` line
<FromGitter> <watzon> Ahh ok, so I did miss it. Editing.
<FromGitter> <Blacksmoke16> the type/api isnt there but i would assume it'll be a thing
<FromGitter> <watzon> Awesome. I love it. Much better than what we have currently.
<FromGitter> <Blacksmoke16> indeed
<FromGitter> <Blacksmoke16> once thats released i can archive crylog :p
<FromGitter> <Blacksmoke16> makes my life a bit easier haha
<FromGitter> <watzon> And I, Strange lol
<FromGitter> <watzon> Not that I've been working on it much anyway
<FromGitter> <Blacksmoke16> @j8r oh i see, where the underlying router could be `Radix`
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <j8r> The docs will depend of what's information is present in `Action` of `Router(Action)`
<FromGitter> <Blacksmoke16> gotcha
<FromGitter> <j8r> I'm wondering, what's the best name to name a method that returns all routes metadata – for now it is `Router#visualize`
<FromGitter> <Blacksmoke16> the yaml implementation they have is prob more doable now with the discriminator thing
<FromGitter> <j8r> Perhaos `#routes`
<FromGitter> <Blacksmoke16> iirc swagger uses `#paths`
<FromGitter> <j8r> `#paths` is good!
<FromGitter> <j8r> One challenge is to have `icyleaf/swagger` an optional dependency
<FromGitter> <Blacksmoke16> only needed if you want the swagger support?
<FromGitter> <j8r> Right 👍
<FromGitter> <Blacksmoke16> i had some thoughts on that as well
<FromGitter> <j8r> I may just create another library
<FromGitter> <Blacksmoke16> that would be one option
<FromGitter> <Blacksmoke16> or just have an optional file that you can require
<FromGitter> <Blacksmoke16> that requires `swagger`
<FromGitter> <j8r> Oh right yes
<FromGitter> <Blacksmoke16> but isnt required directly
<FromGitter> <j8r> Indeed
<FromGitter> <j8r> Great
<FromGitter> <Blacksmoke16> is the solution i ended up on as well
<FromGitter> <j8r> That's also how the stdlib works, too
<FromGitter> <Blacksmoke16> yup
<FromGitter> <watzon> Ever find yourself wishing that we could have object destructuring in Crystal like they have in JS, or is it just me?
<FromGitter> <tenebrousedge> I rarely think to myself that other languages should be more like JS
<FromGitter> <watzon> Same for the most part, but there are some things I like about it
<FromGitter> <tenebrousedge> do you feel like you want this for working with JSON?
<FromGitter> <watzon> ```function foo({bar, baz}) { ⏎ // do something ⏎ }``` ⏎ ⏎ is kinda nice [https://gitter.im/crystal-lang/crystal?at=5e4aed3d46e99d431f80c97f]
ur5us has joined #crystal-lang
<FromGitter> <watzon> Nah, working with objects where I only want a couple values out of the object. The above syntax is a lot nicer than ⏎ ⏎ ```def foo(ctx) ⏎ bar = ctx.bar ⏎ baz = ctx.baz ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5e4aed78d56ddb68a4aead71]
juanfra_ has quit [Quit: killed]
olbat[m] has quit [Quit: killed]
erdnaxeli has quit [Quit: killed]
beepdog has quit [Quit: killed]
* FromGitter * tenebrousedge ponders this
<FromGitter> <watzon> I doubt we'll ever have it in Crystal, but it would be nice ⏎ ⏎ ```def foo({bar, baz} : Bar) ⏎ # do something ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5e4aee1cb401eb68a582bf80]
<FromGitter> <tenebrousedge> welp, time to write a new programming language I guess
<FromGitter> <tenebrousedge> call it Jasper
* FromGitter * watzon laughs
<FromGitter> <watzon> I'm passing in a `context` to all commands which contains several objects, but things end up getting pretty verbose
<FromGitter> <watzon> And I don't want to pass in individual items, because then every command method would have to be written out as `def some_command(client, update, message, command, text)`
<FromGitter> <Blacksmoke16> isnt that more readable tho?
<FromGitter> <tenebrousedge> could you do kwargs?
<FromGitter> <watzon> More readable yes, but not a good API experience if you have to type all that out every time
<FromGitter> <watzon> Which is why being able to destructure the `context` object would be nice
<FromGitter> <Blacksmoke16> that would be more ideal, but considering you would just copy paste it, prob not a big deal either way
<FromGitter> <tenebrousedge> you wouldn't necessarily have to type that out all the time
<FromGitter> <watzon> Fair, it's just a lot to include in every message. That's why I made the `Context` struct to begin with. It would be one thing if they could just choose the items they wanted.
<FromGitter> <watzon> So if they could just do `def some_commmand(message, text)` or `def some_command(update)`
<FromGitter> <Blacksmoke16> couldn't you just make a macro that does it for them
<FromGitter> <watzon> @tenebrousedge how so? You can't omit any values or it won't compile.
<FromGitter> <tenebrousedge> they can do `somecommand(message: m, text: t)`
<FromGitter> <Blacksmoke16> would have to give defaults to other args tho
<FromGitter> <tenebrousedge> `""` is a pretty good default, it seems to me
<FromGitter> <watzon> Except only one of the types is a String
<FromGitter> <watzon> I could make them nilable and default them to nil, but then I have another issue
<FromGitter> <christopherzimmerman> I've been banging my head on this for a while, does anyone see anything wrong with how I bind to this function (https://www.khronos.org/registry/OpenCL/sdk/1.0/docs/man/xhtml/clCreateContext.html)
<FromGitter> <christopherzimmerman> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e4af3e85f82805026e27c5c]
<FromGitter> <watzon> Is the syntax for `pfn_notify` correct? I haven't done much with passing in callbacks.
<FromGitter> <christopherzimmerman> I *think* so, it gets passed as null in the example I'm testing so I don't know if that would impact anything
<FromGitter> <christopherzimmerman> I haven't done much with callbacks either
<FromGitter> <Blacksmoke16> is there an error you're getting?
<FromGitter> <christopherzimmerman> No crystal errors, just an opencl error that says I'm passing an argument incorrectly, but I've run the `clGet_Info` on what I'm passing and it seems to be working
<FromGitter> <christopherzimmerman> Hoping it was something basic, but might just take a lot of messing around
<FromGitter> <watzon> Hmm weird. C sucks guys.
juanfra_ has joined #crystal-lang
<FromGitter> <christopherzimmerman> I feel like the lines I'm not creating right are:
<FromGitter> <christopherzimmerman> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e4af5f618ac9b0fb5c6fe83]
<FromGitter> <christopherzimmerman> `ClContextProperties` is just a `Void*`, so I use `unsafe_as` for casting
<FromGitter> <watzon> Good on you for attempting to wrangle the beast that is OpenCL. This is much needed.
<FromGitter> <christopherzimmerman> I want GPU computing so badly >:
<FromGitter> <watzon> Understandably. So do the people at Nerualegion. I'm sure @bararchy and @ArtLinkov will be happy.
<FromGitter> <watzon> I wonder. I know the macro itself is controversial, but bear with me. Will `forward_missing_to` work twice?
<FromGitter> <watzon> For instance could you `forward_missing_to` one object, and then call it again with another object?
<FromGitter> <tenebrousedge> I don't think so, but `method_missing` could handle it
<FromGitter> <watzon> That's true
<FromGitter> <Blacksmoke16> could you not just do like
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e4af7a19d4c83598b97963d]
<FromGitter> <Blacksmoke16> ```macro "echo", message, text do ⏎ puts message ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5e4af7b29d4c83598b979667]
<FromGitter> <watzon> Hmm yeah actually, that could work
<FromGitter> <Blacksmoke16> changes the dsl but :shrug:
<FromGitter> <watzon> Similarly anyway
<FromGitter> <watzon> I want to keep the annotation syntax though, rather than having them call a block macro, but I think I could make the annotation itself do something like that with the method it's wrapping
<FromGitter> <watzon> I'll have to play with it
<FromGitter> <watzon> Multiple `forward_missing_to` definitely isn't possible https://carc.in/#/r/8kt3 ⏎ `method_missing` it is
<FromGitter> <Blacksmoke16> `parse ctx` that just plops down `message = ctx.message` etc
alexherbo2 has joined #crystal-lang
<FromGitter> <christopherzimmerman> I hate my life, been dealing with this binding for 3 days now, passing the context properties as null infers what you need anyways
beepdog has joined #crystal-lang
olbat[m] has joined #crystal-lang
erdnaxeli has joined #crystal-lang
<FromGitter> <christopherzimmerman> On the bright side:
<FromGitter> <christopherzimmerman> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e4afe2ad56ddb68a4aed9f8]
<FromGitter> <christopherzimmerman> GPU tensors are trivial now
<FromGitter> <watzon> That's awesome
<FromGitter> <christopherzimmerman> I think CUDA will be a lot less trouble
<FromGitter> <watzon> I assume once we have cuda support you could easily have `Num::OpenCL` and `Num::CUDA` or something. Or maybe just have a flag that sets which to use for `Num::GPU`.
<FromGitter> <watzon> The second would probably be better
<FromGitter> <christopherzimmerman> I'll have to put some thought into it, but either way, I'm about to link up all of the `Clblas` and `magma` functionality, which is going to give a huge performance boost to the linear algebra routines.
<FromGitter> <watzon> Fuck yes man. This is a huge step towards better ML compatibility in Crystal.
<FromGitter> <watzon> Hopefully I'll have a laptop with CUDA support soon and I can try and work on those bindings
blackbeard420 has quit [Quit: ZNC 1.7.5 - https://znc.in]
hpyc9 has quit [Quit: ZNC 1.7.5 - https://znc.in]
_ht has quit [Quit: _ht]
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 245 seconds]
blackbeard420 has joined #crystal-lang
<FromGitter> <watzon> Hmm ok, here's an interesting challenge. At least I can't seem to think my way through it right now. I have the following record: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ and the `method_missing` works great, but in some cases, like with `message` and `update`, they have some methods with the same name. Right now if it finds `call` on `message` it will attempt to call it, and potentially fail. I would like
<FromGitter> ... for it to try and call it, and then check again if the method exists on `update` or `client`. [https://gitter.im/crystal-lang/crystal?at=5e4b05f046e99d431f810bbd]
<FromGitter> <Blacksmoke16> ho boy
hpyc9 has joined #crystal-lang
<FromGitter> <Blacksmoke16> uh, just dont use `elsif`?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e4b062fd56ddb68a4aeee8b]
<FromGitter> <watzon> I thought about that, but it will still error when it tries to call the first one that matches
<FromGitter> <Blacksmoke16> error how, runtime exception?
<FromGitter> <Blacksmoke16> ```begin ⏎ message.{{call}} ⏎ rescue ⏎ # Ignore ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5e4b06d20d257250fdf1d7af]
<FromGitter> <watzon> Compiler exception if the method signature doesn't match. The name might be the same, but the params it takes might be slightly different.
<FromGitter> <Blacksmoke16> mm like it taking some arguments or?
<FromGitter> <watzon> I think I may just have to say fuck it haha
<FromGitter> <Blacksmoke16> 🙈
<FromGitter> <watzon> `Chat` isn't being used in this case, so it's not an issue, but these two methods have the same name but a slightly different signature
<FromGitter> <watzon> Also I need to go through these classes and turn them all into records 😢
<FromGitter> <Blacksmoke16> sounds like a pita
<FromGitter> <watzon> For sure haha
<FromGitter> <watzon> Actually I think there's a good reason I used classes. Pretty sure structs were fucking with extending abstract types or something.
<FromGitter> <Blacksmoke16> yea you cant extend a non abstract struct
<FromGitter> <watzon> Pretty sure that's the reason I opted to use classes. Oh well.
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 268 seconds]
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
infinisil has joined #crystal-lang
<infinisil> Hey, how can I turn off stdout buffering, or make it line-based?
<FromGitter> <watzon> What do you mean?
<infinisil> E.g. with this program: https://gist.github.com/c50ae5327a4d601fbf2fb82009c8726f, running `touch file; crystal main.cr | tee file`, and having `tail -f file` in another terminal
<infinisil> This only produces output after the program terminates, before that nothing shows up on the other terminal
<infinisil> Or even just `crystal main.cr | tee` without a second terminal, also doesn't produce any output until it's done
<infinisil> I'm pretty sure this happens because stdout is getting buffered until something like 4KB of chars are written, only then it's flushed. I'd like to make this buffering line-based, such that it flushes for every new line, without having to call flush manually
<FromGitter> <watzon> Well `STDOUT` is an `IO::FileDescriptor` which inherits from `IO::Buffered` which has a property `buffer_size=`
<FromGitter> <watzon> So you should be able to set the buffer size of STDOUT and then write directly to it
<FromGitter> <watzon> Idk if `buffer_size` is right though
<FromGitter> <watzon> https://crystal-lang.org/api/0.32.1/IO/Buffered.html#buffer_size=(value)-instance-method
<FromGitter> <Blacksmoke16> STDOUR.sync = true
<FromGitter> <Blacksmoke16> Us what you want I think
<FromGitter> <watzon> Ahhh there we go
<FromGitter> <Blacksmoke16> Stdout
<FromGitter> <Blacksmoke16> Ofc
<FromGitter> <j8r> Nvidia on Linux is meh :/
<FromGitter> <watzon> Yes it is haha
<infinisil> Hm, it's not line buffering, just not buffering at all with this, but I guess that works
<infinisil> Probably
<infinisil> Actually I want to submit this as a PR to the crystal compiler, because currently --progress doesn't give any live progress if the output isn't a terminal, and making output unbuffered like this should fix it
<FromGitter> <j8r> I wonder if ROCm will gain traction
<FromGitter> <Blacksmoke16> There is also STDOUT.read_buffering = false
<FromGitter> <j8r> infinisil if the outout is not a terminal, the progress will be appended
<FromGitter> <j8r> Normally there are escape sequencies to overwrite text on TTY terminals
<infinisil> So it would be a problem to just set STDOUT.sync = true?
ur5us has quit [Ping timeout: 240 seconds]
ur5us has joined #crystal-lang
<FromGitter> <j8r> No, I just talked about the --progress