ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | 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
Nekka has quit [Ping timeout: 246 seconds]
astronavt has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
aquijoule__ has joined #crystal-lang
aquijoule_ has quit [Ping timeout: 265 seconds]
Nekka has joined #crystal-lang
antoszka has quit [Quit: WeeChat 2.7]
eax has left #crystal-lang [#crystal-lang]
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<FromGitter> <Daniel-Worrall> I think I did a big dumb
<FromGitter> <Daniel-Worrall> ``````
<FromGitter> <Daniel-Worrall> loop do sleep 0.seconds end
<FromGitter> <Daniel-Worrall> It was eating all my cpu
<FromGitter> <Daniel-Worrall> What's the better way to block indefinitely on the main thread
<FromGitter> <Blacksmoke16> `sleep`
<FromGitter> <Daniel-Worrall> That.
<FromGitter> <Daniel-Worrall> Okay.
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 272 seconds]
<FromGitter> <watzon> I really hope there's a focus on improving compile times in the future
<FromGitter> <watzon> Because 42,000 lines of code makes for a long build
<FromGitter> <Blacksmoke16> what crystal version are you on? `0.36.1` i assume?
<FromGitter> <watzon> Yep
<FromGitter> <watzon> I don't even want to know what `--release` would do
<FromGitter> <Blacksmoke16> interesting that `main` takes 13s, i dont see that being too high all too often
<FromGitter> <watzon> Yeah surprised me too
<FromGitter> <watzon> Codegen took a long ass time too
<FromGitter> <Blacksmoke16> i have noticed depending on how/what you code an have a big impact
<FromGitter> <Blacksmoke16> i.e. large unions == no good
<FromGitter> <watzon> Yeah I don't actually have many unions
<FromGitter> <watzon> Or generics
<FromGitter> <watzon> I do have a fuck ton of classes though
<FromGitter> <watzon> Over 1500 generated ones
<FromGitter> <Blacksmoke16> that might do it
<FromGitter> <Blacksmoke16> what happens if you replace the macro code with its static output
<FromGitter> <watzon> Oh it's not a macro
<FromGitter> <Blacksmoke16> oh
<FromGitter> <watzon> I wrote a generator that writes files
<FromGitter> <Blacksmoke16> gotcha
watzon has joined #crystal-lang
f1reflyylmao is now known as f1refly
bougyman has quit [Ping timeout: 258 seconds]
bougyman has joined #crystal-lang
bougyman has quit [Ping timeout: 240 seconds]
bougyman has joined #crystal-lang
ua_ has quit [Ping timeout: 256 seconds]
ua_ has joined #crystal-lang
<FromGitter> <naqvis> this reminds me of https://imgs.xkcd.com/comics/compiling.png
<FromGitter> <naqvis> :P
skrzyp has quit [Ping timeout: 272 seconds]
skrzyp has joined #crystal-lang
<FromGitter> <erdnaxeli:cervoi.se> how can I make this works: https://carc.in/#/r/afii ?
<FromGitter> <erdnaxeli:cervoi.se> I was expected to get a TypeNode, not a Path
<FromGitter> <erdnaxeli:cervoi.se> I don't know how to get a TypeNode
<FromGitter> <erdnaxeli:cervoi.se> from a macro var
<FromGitter> <naqvis> `.resolve` ?
<FromGitter> <naqvis> https://carc.in/#/r/afiu
zorp has quit [Ping timeout: 240 seconds]
_ht has joined #crystal-lang
<FromGitter> <erdnaxeli:cervoi.se> that's seems to be what I am looking for, but it is complaining
<FromGitter> <naqvis> what are you trying to achieve?
<FromGitter> <erdnaxeli:cervoi.se> exactly what the example says: creating a type in a macro, then iterating over this type instance vars
<FromGitter> <naqvis> you can use `@type` inside a macro to get the type
<FromGitter> <erdnaxeli:cervoi.se> the macro is not executed inside the type, the macro is writing the code for the type
<FromGitter> <naqvis> When a macro is invoked you can access the current scope, or type, with a special instance variable: @type. The type of this variable is TypeNode, which gives you access to type information at compile time.
<FromGitter> <erdnaxeli:cervoi.se> my code looks like this: https://carc.in/#/r/afiy
<FromGitter> <erdnaxeli:cervoi.se> instead that inside my {% for %} there is condition to replicated a instance var or not
<FromGitter> <erdnaxeli:cervoi.se> inside this macro @type is Program
<FromGitter> <erdnaxeli:cervoi.se> I don't want that
<FromGitter> <naqvis> problem is you are trying to access the Type which is defined in same macro
<FromGitter> <naqvis> so don't believe AST will have access to that
<FromGitter> <erdnaxeli:cervoi.se> yes exactly
<FromGitter> <naqvis> can you try to separate that in two different macros?
<FromGitter> <erdnaxeli:cervoi.se> sadness…
<FromGitter> <naqvis> better wait for some macro wizards to jump in and see if they have some options :P
<FromGitter> <erdnaxeli:cervoi.se> yep it seems to work with two macros!
<FromGitter> <erdnaxeli:cervoi.se> I tried before but I was missing the .resolve method
<FromGitter> <erdnaxeli:cervoi.se> thanks!
<FromGitter> <erdnaxeli:cervoi.se> https://carc.in/#/r/afj0 <- working solution
<FromGitter> <naqvis> you are welcome
<FromGitter> <naqvis> 👍
<FromGitter> <erdnaxeli:cervoi.se> well now it see no instance vars, but that's something different
<FromGitter> <erdnaxeli:cervoi.se> btw I you have two macros calling each other recursively in a never ending loop, the compiler fails with an invalid memory access ^^
<FromGitter> <naqvis> that seems like a design issue
<FromGitter> <naqvis> I'm not that much into macros and always avoid them until they are really necessary
<FromGitter> <naqvis> so would suggest to wait here, till other persons jump in and provide their valuable thoughts
alexherbo2 has joined #crystal-lang
hightower2 has joined #crystal-lang
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
alexherbo2 has joined #crystal-lang
<FromGitter> <alexherbo2> it's currently not possible to create a File from a fifo no?
<straight-shoota> why not?
<FromGitter> <alexherbo2> because of the blocking
<straight-shoota> File.new just receives a path. It doesn't matter if that path is a normal file or a fifo or whatever
<FromGitter> <alexherbo2> it blocks for reading
<straight-shoota> why is that a problem?
<FromGitter> <alexherbo2> ```fifo = File.new("fifo") # block until receiving data```
<straight-shoota> no
<straight-shoota> File.new just opens the file descriptor
<straight-shoota> it doesn't read until you call a read method
<FromGitter> <alexherbo2> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=602d1aa69403f11bb58b7722]
<straight-shoota> hm
<straight-shoota> so it hangs at openat syscall
alexherbo2 has quit [Ping timeout: 265 seconds]
<straight-shoota> it seems a read-only fifo needs to be opened with O_NONBLOCK
<straight-shoota> then you're right
<straight-shoota> but then ´gets_to_end´ immediately returns when the fifo is empty
<straight-shoota> you would need to call that repeatedly
<FromGitter> <alexherbo2> Is there a workaround to create the File object?
<straight-shoota> I guess you could add your own implementation of Crystal::System::File.open which sets O_NONBLOCK
bazaar has quit [Quit: leaving]
bazaar has joined #crystal-lang
<yxhuvud> You might be able to initialize it using FileDescriptor.new with the blocking flag.
<yxhuvud> it won't be a File, but perhaps good enough.
<FromGitter> <Blacksmoke16> is there a reason you just can do like
<FromGitter> <Blacksmoke16> ```fifo = File.new "fifo" ⏎ fifo.blocking = false``` [https://gitter.im/crystal-lang/crystal?at=602d2363e634904e60a67ff7]
<FromGitter> <Blacksmoke16> cant*
<straight-shoota> @Blacksmoke16 the blocking syscall to openat happens in Crystal::System::File.open and that is called from File.new
<FromGitter> <Blacksmoke16> ah gotcha 👍
<straight-shoota> the blocking property doesn't affect open
<yxhuvud> ah. So what is necessary is to do the open using raw libc and pick out the fd from that and then create a FileDescriptor or the like?
Human_G33k has quit [Remote host closed the connection]
<straight-shoota> yes
<straight-shoota> that would do
<straight-shoota> but I'm really not sure if a fifo with O_NONBLOCK is that useful
Human_G33k has joined #crystal-lang
Human_G33k has quit [Max SendQ exceeded]
Human_G33k has joined #crystal-lang
Human_G33k has quit [Remote host closed the connection]
Human_G33k has joined #crystal-lang
Human_G33k has quit [Quit: Leaving]
Human_G33k has joined #crystal-lang
astronavt has quit [Quit: ...]
riffraff169 has quit [Quit: Leaving.]
<FromGitter> <Oblivious-Oblivious> Hi, how would I go about converting a LibC::Char** to an Array of Strings in Crystal ? ⏎ I found an old GitHub issue (2015) for initializing the pointer on an `Array.new` on that topic however I'm still getting back Pointers. ⏎ ⏎ Specifically I have this. ⏎ ... [https://gitter.im/crystal-lang/crystal?at=602d405e9ba13e72e436882b]
<FromGitter> <Oblivious-Oblivious> Hi, how would I go about converting a LibC::Char** to an Array of Strings in Crystal ? ⏎ I found an old GitHub issue (2015) for initializing the pointer on an `Array.new` on that topic however I'm still getting back Pointers. ⏎ ⏎ Specifically I have this. ⏎ ... [https://gitter.im/crystal-lang/crystal?at=602d409de634904e60a6d96c]
<FromGitter> <Oblivious-Oblivious> Hi, how would I go about converting a LibC::Char** to an Array of Strings? ⏎ I found an old 2015 issue (https://github.com/crystal-lang/crystal/issues/465) on this topic however im still working with an array of Pointer(Pointer(UInt8)) ⏎ ⏎ Specifically I have this: ⏎ ... [https://gitter.im/crystal-lang/crystal?at=602d43734c79215749f14f58]
zorp has joined #crystal-lang
alexherbo2 has joined #crystal-lang
<FromGitter> <naqvis> @Oblivious-Oblivious you need to convert iterate over array of C String and then convert that to Crystal String ⏎ ⏎ ```Array.new(size){|i| String.new(ptr[i])``` [https://gitter.im/crystal-lang/crystal?at=602d546d93539e23437ffa39]
<FromGitter> <naqvis> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=602d54819337c51bc691efaa]
<FromGitter> <Oblivious-Oblivious> @naqvis Ok that gives a list of Strings thanks *
<FromGitter> <naqvis> 👍
<FromGitter> <naqvis> curious to know why you are utilizing FFI for functionality which already exists in stdlib? How your `get_directory_list` is different from `Dir#children or #glob etc`?
<FromGitter> <Oblivious-Oblivious> I had a library for directory walking ready in C when I started the project, which was faster when I first tried it, but I'll probably switch to glob since with recent tests it seems to me glob is as fast as the C alternative.
<FromGitter> <Blacksmoke16> and ofc the obvious question, is fastest possible speed a requirement? I.e. its prob not worth the extra complexity if not just to save like 500ms or whatever
<FromGitter> <Oblivious-Oblivious> I am trying to write software for continuously monitoring hundreds of thousands of files and directories (basically for automatic cloud sync on multiple computers) so we are talking about saving minutes.
<FromGitter> <Blacksmoke16> 👍 fair enough
<FromGitter> <Oblivious-Oblivious> Ofc minutes is fine when mainly syncing code files but still
alexherbo2 has quit [Ping timeout: 260 seconds]
Human_G33k has quit [Remote host closed the connection]
<FromGitter> <lirossarvet> Can anyone explain why the compiler complains about `path` being nil in this case? ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ I've done the check; is this just a natural limitation? Is there a way to...assert to the compiler "I promise it isn't `nil` here, please carry on"? [https://gitter.im/crystal-lang/crystal?at=602d6a5347585464db84f1ac]
<FromGitter> <Blacksmoke16> pretty sure that should work, given you're assigning the value to local var first
<FromGitter> <Blacksmoke16> could also try
<FromGitter> <Blacksmoke16> `if path = some_function...`
<FromGitter> <Blacksmoke16> can you share the exact error?
<FromGitter> <lirossarvet> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=602d6ace726a881d4f7ecfc8]
<FromGitter> <lirossarvet> ```if flags.manifest_path ⏎ puts "Not nil" ⏎ else ⏎ puts "nil" ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=602d6ae4a7fc4b573bde9a24]
Human_G33k has joined #crystal-lang
<FromGitter> <lirossarvet> Sorry the `Dir.cd` should be there, but...yeah. Trying to sanitize the logic 😅
<FromGitter> <Blacksmoke16> yea thats not going to work because of https://crystal-lang.org/reference/syntax_and_semantics/if_var.html#limitations
<FromGitter> <Blacksmoke16> would want to do like `if path = flags.manifest_path`
<FromGitter> <lirossarvet> Ah geez, thanks. I thought I'd tried the local variable one but missed one somewhere, I guess.
Human_G33k has quit [Max SendQ exceeded]
<FromGitter> <lirossarvet> Definitely very new to Crystal. Trying it out at our Ruby shop company as a compiled, shareable CLI for common stuff we do :D
<FromGitter> <Blacksmoke16> 👍 nice
<FromGitter> <Blacksmoke16> keep in mind if you're on mac you cant statically compile, so may need to install a few libs
<FromGitter> <lirossarvet> Yeah. For the most part things have been fine cause we aren't doing crazy complex stuff, but definitely something to keep in mind :)
<FromGitter> <Blacksmoke16> 👍
Human_G33k has joined #crystal-lang
alexherbo2 has joined #crystal-lang
eax has joined #crystal-lang
eax has left #crystal-lang [#crystal-lang]
sz0 has joined #crystal-lang
deavmi has quit [Ping timeout: 240 seconds]
deavmi has joined #crystal-lang
<FromGitter> <perfecto25> hello, anyone aware of any crystal libs that can do multicast connectivity to mcast IP and port?
<FromGitter> <perfecto25> trying to build a multicast listener that can connect to mcast group and port, do basic conectivity sanity check
deavmi has quit [Ping timeout: 272 seconds]
_ht has quit [Remote host closed the connection]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
alexherbo2 has quit [Ping timeout: 240 seconds]
hightower2 has quit [Ping timeout: 256 seconds]
alexherbo2 has joined #crystal-lang
deavmi has joined #crystal-lang
Human_G33k has quit [Quit: Leaving]
Human_G33k has joined #crystal-lang
<FromGitter> <watzon> This has to be the quickest issue->pr turnaround I've ever seen https://github.com/crystal-lang/crystal/issues/10402#event-4341737656
<FromGitter> <watzon> @mrx seems like the built in UDPSocket is multicast capable https://crystal-lang.org/api/0.36.1/UDPSocket.html
Welog has joined #crystal-lang
Human_G33k has quit [Remote host closed the connection]
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
Human_G33k has joined #crystal-lang