<FromGitter>
<drosehn> Are there some crystal-provided constants for the compile-time and compile-date of your program? (not BUILD_DATE, which is the date the compiler was built).
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 265 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
cyberarm has quit [Read error: Connection reset by peer]
cyberarm has joined #crystal-lang
radagast has quit [Quit: radagast]
oprypin has quit [Read error: Connection reset by peer]
FromGitter has quit [Ping timeout: 272 seconds]
vivus has quit [Read error: Connection reset by peer]
oprypin has joined #crystal-lang
FromGitter has joined #crystal-lang
rohitpaulk has joined #crystal-lang
snsei has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
relyks has joined #crystal-lang
<relyks>
are there any plans to add auto-completion to crystal?
daemonwrangler has quit [Quit: ZNC 1.6.5 - http://znc.in]
daemonwrangler has joined #crystal-lang
braidn_ has quit [Ping timeout: 248 seconds]
wmoxam has quit [Ping timeout: 248 seconds]
chrisarcand has quit [Ping timeout: 248 seconds]
chrisarcand has joined #crystal-lang
wmoxam has joined #crystal-lang
<FromGitter>
<potz> > Are there some crystal-provided constants for the compile-time and compile-date of your program? (not BUILD_DATE, which is the date the compiler was built). ⏎ ⏎ I don't know the answer to your exact question, but was just playing around with macros and apparently you can do something like this: ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=5a4460100163b02810867f23]
g3funk has joined #crystal-lang
wmoxam has quit [Ping timeout: 248 seconds]
wmoxam has joined #crystal-lang
relyks has quit [Quit: relyks]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
<FromGitter>
<drosehn> Hmm, yes, something like that would work. I've moved on from the program where I wanted that, but that would get the job done and would give me some flexibility in the exact format of time. I'll remember this for when I get back to that program.
<FromGitter>
<drosehn> Thanks for that suggestion.
<FromGitter>
<potz> cool, you're welcome.
<FromGitter>
<potz> I wonder if there's a way to just run `Time.now` inside the macro, probably a better idea.
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 272 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 265 seconds]
<FromGitter>
<drosehn> The macro language is it's own little separate language. What it knows how to do is documented at https://crystal-lang.org/api/Crystal/Macros.html . You could maybe use `run()` instead of `system()`, because it looks like `run()` compiles and runs the file you specify. But in this case that's more trouble than it's worth, because it means you'd need a separate source file which had nothing but a command to
<FromGitter>
... print out `Time.now`.
<FromGitter>
<drosehn> Although using the `run()` command in the macro language might work better when writing something which is meant to be compiled on multiple platforms. But for what I'm doing, it's fine to use `now_as_int = {{system %q(date +%s)}}`
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
<crystal-gh>
[crystal] bcardiff closed pull request #5458: Fix missing Dir#each to be an Enumerable (release/0.24...fix/dir_each) https://git.io/vb5uj
<FromGitter>
<straight-shoota> @bararchy This doesn't depend on multi-threading, waiting for a set of fibers to complete is also useful if they are "only" concurrent.
<FromGitter>
<straight-shoota> And there is actually a macro for that: `parallel`
<FromGitter>
<bararchy> @straight-shoota Interesting, there is no api docs reagrding this macro, looking at the code it seems it create a Channel per job, and execute each in a spawn while waiting for all to finish right?
<FromGitter>
<bararchy> is there a simple example of how this actually works?
<FromGitter>
<bararchy> do I feed it an Array(Proc) ?
<FromGitter>
<bararchy> Or better (easier?) is there a spec for it?
<FromGitter>
<straight-shoota> I don't know much about it besides looking at the code myself
<FromGitter>
<straight-shoota> But it is specced in spec/std/concurrent_spec.cr
<FromGitter>
<straight-shoota> It's a macro, so just feed it plain expressions, no procs involved.
mjago` has quit [Quit: ERC (IRC client for Emacs 25.1.1)]
jsn- has quit [Ping timeout: 260 seconds]
jsn- has joined #crystal-lang
jnyw has joined #crystal-lang
<FromGitter>
<straight-shoota> no, `parallel` is for running several distinct tasks where each is defined differently and you might want individual return values. Your code is essentially running the same task distributed over multiple fibers.
<FromGitter>
<straight-shoota> there should probably be a macro for that, too. Or rather a method because there is no macro involved.
<FromGitter>
<potz> @drosehn agreed. So it's my understanding that `run()` always needs the macro code in a separate file? I was hoping there would be some sort of `quote`/`unquote` a la Elixir somewhere.
snsei has quit [Remote host closed the connection]
<FromGitter>
<drosehn> Not only does `run()` need a separate file, but the documentation notes that the compiler may cache the result of the last time it compiled that file.
snsei has joined #crystal-lang
<FromGitter>
<potz> I see.. definitely not good for timestamping then
<FromGitter>
<drosehn> for your amusement, this seems to work okay:
<FromGitter>
<potz> So *FILE* is always compile-time, obviously...
<FromGitter>
<potz> I mean `__FILE__`
<FromGitter>
<drosehn> yes.
<FromGitter>
<potz> Well thinking a bit more, even if the macro-file that is run by `run` is cached, if you provide a method on it that just returns `Time.now`, it would still work right.
<FromGitter>
<potz> I mean, it caches the compiled code, but executing it would always yield the current time
<FromGitter>
<potz> I suppose if you have a lot of macro-related helpers it's not a big deal to have a separate file, might even be a good practice
<FromGitter>
<potz> I'm finding all this fascinating. Just started messing around with crystal 2 days ago.
snsei has quit [Ping timeout: 265 seconds]
rohitpaulk has quit [Ping timeout: 252 seconds]
<FromGitter>
<drosehn> Well, I'm still half-asleep, so I'm not sure if it would work right.
<FromGitter>
<drosehn> ... and I need to concentrate my half-asleep brain on a different project right now, but thanks again for the idea about using `system()`.
<FromGitter>
<potz> lol ok. I wish you a good `sleep 8.hours` at some point in the future
<FromGitter>
<drosehn> Probably not for another 12 hours!
<FromGitter>
<potz> @larubujo Oh I see what you mean.... ``date`` (with backticks), being equivalent to system("date"). The gitter interface transformed your original message.
<livcd>
few questions :-)
<livcd>
1) what is the most stable and/or featerful DB driver available for Crystal ?
<FromGitter>
<marksiemers> If you look at the links from that page, for sqlite, mysql, and postgres, those are the most stable drivers.
<FromGitter>
<marksiemers> For features, are you looking for an ORM, or particular features from the driver?
<livcd>
marksiemers: my q is kinda generic and more about "which one would you use in production all things considered (like Crystal not being 1.0 yet and so on)
rohitpaulk has joined #crystal-lang
claudiuinberlin has joined #crystal-lang
Ven`` has joined #crystal-lang
<FromGitter>
<bararchy> I posted to the google group, and copy-pasting here for those not in the Crystal group
<FromGitter>
<bararchy> Hi All, ⏎ ⏎ As you might have heard (or not) we released our WIP neural network SHAInet to github under the MIT license. ⏎ The network is planed to be a full toolkit allowing users to train, use, and re-use multiple interesting architectures all in pure Crystal (no C bindings) ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5a455715e43a7a150cb6601f]
gloscombe has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.0.1]
rohitpaulk has quit [Ping timeout: 248 seconds]
marius has joined #crystal-lang
Ven`` has quit [Ping timeout: 240 seconds]
Ven`` has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
snsei has joined #crystal-lang
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
TIMEBONEZ has quit [Ping timeout: 240 seconds]
claudiuinberlin has joined #crystal-lang
snsei has quit [Ping timeout: 265 seconds]
TIMEBONEZ has joined #crystal-lang
gloscombe has quit [Ping timeout: 272 seconds]
gloscombe has joined #crystal-lang
snsei has joined #crystal-lang
<FromGitter>
<vpereira> Hi, I'm playing with crystal and concurrency
<FromGitter>
<vpereira> so its works. However Imagine that I want to remove the "sleep 5"
<FromGitter>
<vpereira> how can I ensure, to close the channel just after both fibers ended?
<RX14>
@vpereira count the fibers you spawn (2), receive 2 times, then close the channel
<RX14>
if you don't know how many times each fiber will send in a channel, create another "completion" channel which each fiber sends nil down once it's done
<RX14>
once each fiber has sent something down the completion channel, you know it's all done and you can cleanup
<RX14>
but in this case your completion channel can be the same as your "data" channel
<FromGitter>
<vpereira> RX14. thank you. Count isnt an option. I actually tried the control channel but the code looked too complex. lets see
snsei has quit [Remote host closed the connection]
<RX14>
@vpereira we really need to have some higher-level concurrency primitives
<RX14>
I don't know if there are any shards which do that
<FromGitter>
<vpereira> RX14 I'm searching all day for that. No success :/
jnyw has joined #crystal-lang
<RX14>
you can get everything done with fibers and channels of course
<RX14>
it's just a little lengthy
<RX14>
you should probably create a "wait group" abstraction of something
<RX14>
or*
<FromGitter>
<vpereira> yes, maybe.. Do you know any shrad which works heavily with channels and fibers? I would like to study some code and get some ideas of how to solve those problems
<RX14>
no, sorry I don't
<RX14>
@vpereira looks like you need to create this shard
<RX14>
i'm sure the community would be happy for it
<RX14>
and i'd love to include some of this in the stdlib
<FromGitter>
<vpereira> RX14: lol I'm an average ruby developer but a mediocre go developer. I'm still trying to get my feet wet with crystal ;)
<RX14>
i'm sure whatever you create will be far better than nothing
<RX14>
if you're reaching for it there's a need
<FromGitter>
<vpereira> until now I couldnt find a difference between "calling a Fiber.yield" after my spawn blocks and not calling it