<FromGitter>
<jaydorsey> good evening. was wondering if someone could help me understand what might have changed recently with File.real_path?
<FromGitter>
<jaydorsey> I used to be able to do `File.real_path(“bin”)` for example, and it would read that path. Now, it seems to die on every folder with an error message ```Unhandled exception: Error resolving real path of 'foo': No such file or directory (Errno) ⏎ from /Users/jay/.asdf/installs/crystal/0.31.1/src/crystal/system/unix/file.cr:92:5 in 'real_path' ⏎ from /Users/jay/
<FromGitter>
... .asdf/installs/crystal/0.31.1/src/file.cr:554:5 in 'real_path' ⏎ from test.cr:1:1 in '__crystal_main' ⏎ from /Users/jay/.asdf/installs/crystal/0.31.1/src/crystal/main.cr:97:5 in 'main_user_code' ... [https://gitter.im/crystal-lang/crystal?at=5dbf9f252f8a034357304609]
<FromGitter>
<jaydorsey> I just remembered I recently upgraded to macOS catalina on both my work and home computers, so i wonder if that might be related
<FromGitter>
<jaydorsey> I tried giving the app I built full disk access via System Prefs and the error still occurs
<FromGitter>
<jaydorsey> I’m actually going to open a bug report here. This is really problematic for the little toy app I’m reading, but I’m pretty certain this is a bug/behavior w/ macOS catalina only
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 240 seconds]
<FromGitter>
<Daniel-Worrall> Is `Fiber.yield` not working properly? my program is exiting without passing to the fibers
<FromGitter>
<watzon> @Daniel-Worrall have a working code sample?
<FromGitter>
<Daniel-Worrall> It works completely fine with sleep
<FromGitter>
<Daniel-Worrall> I got doc links up but ty
<FromGitter>
<Daniel-Worrall> I'll go issue this yield
<FromGitter>
<watzon> Yeah it seems like an issue
<FromGitter>
<Daniel-Worrall> Hm why don't any of the Dir methods accept a `Path` object
<FromGitter>
<watzon> Good question
ht_ has quit [Remote host closed the connection]
<devil_tux>
:q
devil_tux has quit [Quit: leaving]
<FromGitter>
<watzon> Weird
<FromGitter>
<watzon> `"/" == '/'` is false
<FromGitter>
<watzon> I would've thought that it would be true
<FromGitter>
<yxhuvud> One is a string, one is a char.
<FromGitter>
<watzon> Well yeah, but they should be equal. For instance `1.0 == 1` is true, even though one is a `Int32` and the other is a `Float64`
<FromGitter>
<watzon> I could swear `Char`s and `String`s use to be able to be tested for equality
return0e has joined #crystal-lang
return0e_ has quit [Ping timeout: 268 seconds]
DTZUZO has quit [Ping timeout: 268 seconds]
<FromGitter>
<absolutejam_gitlab> @Daniel-Worrall I asked this on the forums and it's because the `Path` module is relatively new
<FromGitter>
<absolutejam_gitlab> Makes sense to move to that direction though
<oprypin>
@Daniel-Worrall: i think the main direction is to have methods on the Path object instead. not that it can always work out well...
<FromGitter>
<lbarasti> @Daniel-Worrall @watzon, that's the expected behaviour for `Fiber.yield`. In the example above ⏎ ⏎ 1) The main fiber suspends and the scheduler puts it in the queue. ⏎ 2) The other fiber starts, issues the HTTP call and suspends, waiting for a response ⏎ 3) The scheduler picks the main fiber, as no other fibers are ready to run, and the program terminates [https:
<repo>
unrelated question: i tried to run the following query with will/crystal-pg: `db.query_all("SELECT * FROM log_messages WHERE ts_message @@ to_tsquery(?)", args: ["foo"])` but got a syntax error at or near ")"
<repo>
the query (with expanded args) `SELECT * FROM log_messages WHERE ts_message @@ to_tsquery('foo');`worksfine
<repo>
(in psql shell that is)
DTZUZO has joined #crystal-lang
duane has joined #crystal-lang
DTZUZO has quit [Ping timeout: 268 seconds]
HumanG33k has quit [Ping timeout: 245 seconds]
HumanG33k has joined #crystal-lang
<FromGitter>
<Daniel-Worrall> ah, I thought Fiber.yield made guarantees about finishing execution. Guess I'll need to make a channel and receive x amount of times
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
<FromGitter>
<asterite> repo: use `$1` instead of `?`
<jhass>
we should rename Fiber.yield to Fiber.yield_dont_use_me_use_a_channel_instead :D
HumanG33k has quit [Ping timeout: 265 seconds]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
duane has quit [Ping timeout: 246 seconds]
<FromGitter>
<yxhuvud> No.
duane has joined #crystal-lang
<FromGitter>
<yxhuvud> also the same issue exist with threads, in about every language I've seen that doesn't do structured concurrency with cancellation
DTZUZO has joined #crystal-lang
ht_ has joined #crystal-lang
<FromGitter>
<sam0x17> XD
<FromGitter>
<sam0x17> fibers + channels is pretty badass. I did a 500 file S3 upload concurrently the other day with a spawn block and it didn't crash and did complete and was quick
<FromGitter>
<sam0x17> also didn't use crazy amount of ram
<FromGitter>
<sam0x17> all the small files (about 150) finished in the first 2 seconds, and then the large files all finished around the same time a minute later
<FromGitter>
<sam0x17> so it really was doing tons of uploads at the same time
<FromGitter>
<sam0x17> mind you this is on a gigabit connection
<hightower3>
ahm, again not quite there yet because I need to be aware of both key and value. transform_* functions seem to only give key or value, not both
<hightower3>
ok n/m, will rethink the approach
<FromGitter>
<Blacksmoke16> each_with_obj might be the better approach
<FromGitter>
<Blacksmoke16> could prob do like
<FromGitter>
<Blacksmoke16> prob should just make a new hash then use .each to set values on that new hash
<hightower3>
yes, most probably. Once I resort to specifying the type manually all options are open. Thanks.
<hightower3>
mm.. I also thought of using Hash[...] which is supported in ruby and sometimes support really interesting ways of constructing the object, but I see [] isn't supported here.
<hemite>
Am I missing something in the crystal vscode plugin? It seems it seems that "go to definition" does not work
<FromGitter>
<tenebrousedge> no idea. I quit using vscode for Crystal because it didn't seem like much use. Spacevim has a reasonable level of support
<hemite>
completion, goto definition, and proper debug support ( stack traces )?
<FromGitter>
<asterite> hightower3: maybe to_h with block?
<FromGitter>
<tenebrousedge> hightower3 you may also be able to find some interesting uses for the default block hash syntax
<hemite>
tenebrousedge ^^
<FromGitter>
<asterite> hemite: I don't think any crystal IDE out there has good support for completion, go to definition, etc.
<FromGitter>
<tenebrousedge> and Crystal in general doesn't have great debug support
<hemite>
Ah ok, thanks guys
<hemite>
and also 😞
teardown has quit [Ping timeout: 276 seconds]
<hightower3>
mm asterite, intesting. Speaking of which, why isn't to_h with the block variant listed in methods on https://crystal-lang.org/api/master/Hash.html ? (It only shows up in popup if I hover the mouse over Enumerable's methods
<FromGitter>
<Blacksmoke16> prob because its inherited from Enumerable and not directly defined on Hash
<FromGitter>
<asterite> yes, that ^
<hightower3>
yes, yes, I meant, it seems like extra step needed from the reader to click there and check... but, if you didn't receive similar reports then probably I'm just not used to it.
<hightower3>
asterite but yeah, to_h seems very nice, thanks
<FromGitter>
<asterite> cool! :-)
<FromGitter>
<asterite> I think it might be overkill to inline list all inherited methods. In Java and other OOP languages it's the same: parent methods are listed separately, just a short mention to them
teardown has joined #crystal-lang
<FromGitter>
<christopherzimmerman> Is there a way to access the results of two iterators in a block if I know the size of them in advance? ⏎ ⏎ Something like ⏎ ⏎ ``` a = (1...6).each ⏎ b = (3...8).each ⏎ ⏎ Pointer.malloc(5) { |i| a.next + b.next }``` [https://gitter.im/crystal-lang/crystal?at=5dc08af69c39821509e2c4c2]
<FromGitter>
<tenebrousedge> You can `zip` them
<hightower3>
tenebrousedge yep found it, but it seemed too far away from elegance I wanted
<FromGitter>
<tenebrousedge> hightower3 do you have a code example?
<hightower3>
I thought I have it with to_h, but I got compiler exception which I can't reproduce on play. Playing around with it now.
<FromGitter>
<christopherzimmerman> I don't think zipping them solves the problem of accessing them inside that block, unless I am missing something
<hightower3>
christopherzimmerman yes, yes, the zip option would entail something like zip( hsh.keys, hsh.map{|k,v| transform(k,v)} )
<FromGitter>
<tenebrousedge> `zip` lets you access them in *a* block
<FromGitter>
<tenebrousedge> you could probably use `with_object` or `reduce` if you needed to
<hightower3>
and with a block, yes (again one documented in Enumerable :)
duane has joined #crystal-lang
dwdv_ has left #crystal-lang ["leave"]
twistedpixels has joined #crystal-lang
<FromGitter>
<ImAHopelessDev_gitlab> @wontruefree nice, I hope it gets recorded
<FromGitter>
<Daniel-Worrall> I've done some duktape.cr testing before but hadn't thought to bake the lib inside the shard and makes things a lot easier
<FromGitter>
<sam0x17> I've also published bindings for clean-css (github.com/sam0x17/css-minifier) and uglifyjs (github.com/js-minifier) however still cleaning those up
<FromGitter>
<sam0x17> my goal is to get amber and lucky etc to drop any npm/node dependencies , but need to offer a fully viable pipeline first
<FromGitter>
<sam0x17> it's horrifying that state of the art minification relies on npm these days
<FromGitter>
<sam0x17> main thing I want to clean up is I wasn't aware of the `read_file` macro, so I was relying on `baked_filesystem` in palces where I didn't need to
<FromGitter>
<sam0x17> that and docs
<FromGitter>
<sam0x17> and making sure options work
<FromGitter>
<ilanpillemer> how do you create a second reference to the same class?
<FromGitter>
<sam0x17> @Daniel-Worrall one comment I have, you might want to only initialize the duktape context on the first use rather than at startup
<FromGitter>
<Daniel-Worrall> I believe it is doing that already
<hightower3>
yeah I mean something that is one keypress, without modifiers or extra keys
<FromGitter>
<Daniel-Worrall> Or you can put things on the stack and use duk_call yourself
<FromGitter>
<Daniel-Worrall> I'd do it the second way but there's a convenience method so whatever
<FromGitter>
<sam0x17> that percent stuff (if you're talking about what I think you're talking about) is one of my hated ruby things
<FromGitter>
<sam0x17> I see it and it looks like greek
<FromGitter>
<tenebrousedge> since every character can appear in a string, there's not going to be a single-character string syntax that won't be obnoxious for some strings
<FromGitter>
<Daniel-Worrall> See duktape.org/api.html#duk_call
<FromGitter>
<sam0x17> thx
<FromGitter>
<sam0x17> ahhh, so you can just give it a string directly
<FromGitter>
<sam0x17> yeah, that solves that
<FromGitter>
<Daniel-Worrall> Or see duktape.cr reader Runtime example
<FromGitter>
<tenebrousedge> the percent-syntax allows you to choose your delimiters; that's as good as you can get
<FromGitter>
<Daniel-Worrall> Readme*
ht_ has quit [Quit: ht_]
<FromGitter>
<sam0x17> @tenebrousedge yeah it's very good design wise, I just dont like how it looks visually
<FromGitter>
<sam0x17> for me crystal and ruby is all about asthetics
<FromGitter>
<sam0x17> or largely
<FromGitter>
<tenebrousedge> I would say they're about flexibility, Ruby in particular
<FromGitter>
<sam0x17> and you'd be right
<FromGitter>
<sam0x17> I'm just stubborn
<FromGitter>
<tenebrousedge> the flexibility allows you to choose an aesthetically pleasing form
<FromGitter>
<tenebrousedge> usually
<FromGitter>
<sam0x17> but yeah on that note, I would happily sacrifice character literals for single quoted strings in crystal
<FromGitter>
<tenebrousedge> what do you think about Ruby's `?` char literals?
<FromGitter>
<sam0x17> maybe do some type magic where a string of length 1 *is* a char
<FromGitter>
<tenebrousedge> `?A` => `'A'`
<FromGitter>
<Daniel-Worrall> I like the flexibility given by being able to define chars easier
<FromGitter>
<sam0x17> oh I love that
<FromGitter>
<sam0x17> @tenebrousedge
<FromGitter>
<tenebrousedge> I mean, what exactly is the semantic difference between a single-char string and a char?
<FromGitter>
<sam0x17> I was just brainstorming in my head and had come up with basically that
<FromGitter>
<sam0x17> didnt realize ruby had that
<FromGitter>
<sam0x17> also my question
<FromGitter>
<tenebrousedge> I think people hate it and rubocop tells you it's bad, but it's there
<FromGitter>
<sam0x17> I bet it has to do with memory layout
<FromGitter>
<sam0x17> rubocop will tell you whatever you tell it's cops to tell you
<FromGitter>
<tenebrousedge> yeah, I read through all the cops and wrote my own .rubocop.yml
<FromGitter>
<sam0x17> yup same
<FromGitter>
<sam0x17> I used to work somewhere where more than 10 line function was a rubocop no-no
<FromGitter>
<sam0x17> NEVER AGAIN
<FromGitter>
<tenebrousedge> I'm forcing myself to write comments for every method :( I hate me
<FromGitter>
<sam0x17> there is such a thing as a self-documenting method name ;)
<FromGitter>
<tenebrousedge> Probably :/ but it's still probably good to document the expected input and return types, and suchlike
<FromGitter>
<watzon> It would be nice if there was a way to do `a, b, c = string.split(' ')` where the assignment will just be `nil` if there aren't enough items in the array
<FromGitter>
<Blacksmoke16> what happens now? out of bounds?
<hightower3>
What am I missing here.. I define function taking arg `data : IO | IO::FileDescriptor`. Inside function, I call data.size, and this gives compile error: undefined method size for IO::ARGF (compile-time type is (IO | IO::FileDescriptor))
<hightower3>
Why is it mentioning IO::ARGF when I've limited the types
<hightower3>
or IO didn't limit it?
<hightower3>
fg
<FromGitter>
<tenebrousedge> ARGF is presumably an `IO`
<FromGitter>
<tenebrousedge> to narrow types though, you want to use `as`
<FromGitter>
<watzon> There's no real reason for the union as far as I can tell
<FromGitter>
<watzon> `IO | IO::FileDescriptor` will always match `IO`
<FromGitter>
<watzon> May as well just have `data : IO`
<hightower3>
yeah I wanted some more specific type