<FromGitter>
<Blacksmoke16> well its not going to work if you pass in the language at runtime
<FromGitter>
<Blacksmoke16> since macros are compile time
<FromGitter>
<rmarronnier> Hmm so self.stop_words should be a macro method ?
<FromGitter>
<Blacksmoke16> without knowing the whole problem, hard to say
<FromGitter>
<Blacksmoke16> whats the end goal you're trying to accomplish?
<FromGitter>
<rmarronnier> I want to let the developer choose which file(s) (i18n list of words) she needs whitout loading all files when compiling
<FromGitter>
<rmarronnier> for example she should be able to set `language = "ru"` and only the ru.txt will be read at compile time
<FromGitter>
<Blacksmoke16> but also able to load multiple?
<FromGitter>
<rmarronnier> Yes, exactly !
<FromGitter>
<Blacksmoke16> i dont suppose you could use an env var, split that, iterate over the names, load each file and concat into a big string
<FromGitter>
<Blacksmoke16> or use a constant thats an array of languages
<FromGitter>
<rmarronnier> Mmm, I think I'm starting to understand that what I'm trying to do is impossible (feed macros values with dynamically set variables)
<FromGitter>
<Blacksmoke16> can only do that via annotations, constants, or env vars
<FromGitter>
<Blacksmoke16> cant use runtime values as macros would already be resolved by then
<FromGitter>
<rmarronnier> Yeah.. and crystal compiler isn't smart enough to guess which runtime values are possible vs impossible :-p
<FromGitter>
<rmarronnier> Thanks for the tips
<FromGitter>
<Blacksmoke16> depending on the context it couldnt possibly know
<FromGitter>
<rmarronnier> yep
<FromGitter>
<nsuchy> Does crystal have a good Apache Cassandra library?
<FromGitter>
<Blacksmoke16> UX is still up in the air, debating if its ok to require the user to call `validate` once and pass the groups to that vs valid?
<FromGitter>
<Blacksmoke16> im thinking it is
ukd1 has quit [Quit: leaving]
chemist69 has quit [Ping timeout: 250 seconds]
chemist69 has joined #crystal-lang
gangstacat has quit [Quit: Ĝis!]
ht_ has joined #crystal-lang
fyber has quit [Remote host closed the connection]
<cerulean>
sup all? My crystal game is nearly completion
<cerulean>
it's my first game ever
<cerulean>
the prototype works somewhat
<cerulean>
give me a few days to get iit perfect and i will show you guys
<cerulean>
I used PixiJS
ht_ has quit [Remote host closed the connection]
docelic has joined #crystal-lang
<FromGitter>
<j8r> cerulean can't wait to try it out :)
docelic has quit [Ping timeout: 258 seconds]
dingenskirchen has quit [Ping timeout: 246 seconds]
dingenskirchen has joined #crystal-lang
<FromGitter>
<bew> @Blacksmoke16 nice, groups are a good idea! Not sure about `.valid? some_array` though, I'd do without the array for the most common case (like: `.valid? "one"` or `.valid? "one", "two"`), so we avoid an array allocation for "nothing", but still allow to pass an array if you already have one
<FromGitter>
<bew> And you already know my opinion on `.validate`, I wouldn't want to have a desynchronization between the checks and the `.valid? xx` call. Calling `.valid?` should do the checks (with optional caching of the result)
alex`` has joined #crystal-lang
DTZUZO has quit [Ping timeout: 268 seconds]
<FromGitter>
<Blacksmoke16> it just feels weird to me to have to pass the groups in `.valid?` as well
<FromGitter>
<Blacksmoke16> it should be something that happens when you call `.validate`
<FromGitter>
<Blacksmoke16> @bew thoughts on dropping `.valid?` in favor of like `.validate("one", "two").empty?`
<FromGitter>
<Blacksmoke16> change validate to return the errors if any
PMunch has joined #crystal-lang
<PMunch>
Hi everyone. We have an interesting (hopefully) proposal for you! Since last years FOSDEM conference the people over in #nim have been talking about creating a developer room for small/new/unknown languages. The room will feature presentations about parts of the language, or specific cool projects done in a language. If anyone from the Crystal community wants to join in on the effort, come join us over in #fosdem19newerlangs.
<Stephie>
PMunch, channel doesn't seem to exist?
<Stephie>
i'm *probably* going to fosdem 19
<FromGitter>
<alehander42> it's on freenode
<Stephie>
this is freenode
<FromGitter>
<alehander42> ahh
<Stephie>
well
<FromGitter>
<alehander42> then you can copy #fosdem19newerlangs
<Stephie>
i'm on freenode :)
<FromGitter>
<alehander42> without the `.`
<FromGitter>
<alehander42> in the end
<Stephie>
i did
<Stephie>
channel is empty
<PMunch>
Weird, we're three people in there (plus ChanServ)
<Stephie>
whoops
<Stephie>
it did copy the dot
<FromGitter>
<alehander42> : P
<PMunch>
Yeah, my IRC client also highlighed the dot as part of the name
coderobe has quit [Remote host closed the connection]
gangstacat has joined #crystal-lang
lucasb has joined #crystal-lang
coderobe has joined #crystal-lang
coderobe has quit [Ping timeout: 245 seconds]
coderobe has joined #crystal-lang
sorcus has quit [Read error: Connection reset by peer]
sorcus has joined #crystal-lang
PMunch has quit [Remote host closed the connection]
mntmn has quit [Ping timeout: 250 seconds]
OvermindDL1 has quit [Ping timeout: 250 seconds]
CommanderViral has quit [Ping timeout: 250 seconds]
OvermindDL1 has joined #crystal-lang
mntmn has joined #crystal-lang
ht_ has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter>
<Blacksmoke16> actually @bew, can you think of any use case that would require running validations a bunch of times? I.e. that would make cacheing them make sense?
<FromGitter>
<Blacksmoke16> you know about the `crystal init` command?
<FromGitter>
<nsuchy> @Blacksmoke16 Yeah, this is specifically for amber though
<FromGitter>
<nsuchy> to make crystal web apps even easier for GitLab users who've never used crystal before
<FromGitter>
<Blacksmoke16> 👍
<FromGitter>
<nsuchy> this is great exposure to a huge userbase
rohitpaulk has quit [Ping timeout: 244 seconds]
alex`` has quit [Read error: Connection reset by peer]
alex`` has joined #crystal-lang
go|dfish has quit [Ping timeout: 246 seconds]
go|dfish has joined #crystal-lang
<FromGitter>
<Blacksmoke16> i hope so, we shall se
gangstacat has quit [Quit: Ĝis!]
gangstacat has joined #crystal-lang
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
sagax has joined #crystal-lang
<FromGitter>
<nsuchy> waiting to see what peeps say
fyber has joined #crystal-lang
fyber has quit [Client Quit]
fyber has joined #crystal-lang
<FromGitter>
<rmarronnier> ok, tell me if I'm wrong : ⏎ 1- I create a module with a macro defining a method which reads a file at compile time with `{{ read_file("#{__DIR__}/a/static/path/blabla.txt") }}` ⏎ 2- I include this module in a class located in another file whose `__DIR__` is different. ⏎ 3- The read_file obviously fails. ⏎ 4- There is no strategy to have the `read_file` macro works in this scenario. ...
<FromGitter>
<asterite> Store `__DIR__` in a constant in that module, then reference it in the macro
<FromGitter>
<asterite> but I18N is something that most likely users choose at runtime, I wouldn't try to do all of that with macros
<FromGitter>
<rmarronnier> Nice @asterite !
<FromGitter>
<asterite> did that work?
<FromGitter>
<rmarronnier> No, but I'm hopeful :-D
<FromGitter>
<asterite> haha
<FromGitter>
<j8r> @rmarronnier why do you want absolutely use a constant?
ht__ has joined #crystal-lang
ht_ has quit [Ping timeout: 250 seconds]
<FromGitter>
<j8r> `{{ env("MY_PATH") }}` would do it
<FromGitter>
<rmarronnier> I want this macro to be called wherever the developer needs to call it. This macro gives her/him a list of stop words. I want it to be determined at compile time so that the library is batteries-included without forcing the developer to grow the binary with 50 languages files if she doesn't them
ht__ is now known as ht_
<FromGitter>
<watzon> Oh hey @rmarronnier lol
<FromGitter>
<watzon> You're working on Cadmium stuff right?
<FromGitter>
<rmarronnier> yeah :-)
<FromGitter>
<rmarronnier> I'm struggling hard on things that seemed simple at first :-D But asterite tip put me in a good way
<FromGitter>
<watzon> @j8r the problem is this: currently Cadmium has only a list of English stop words, which can easily be stored in a Crystal array and loaded at compile time. What we want to do is expand those stop words to multiple languages. Originally I had things being stored in a json file in a data directory, but the problem is if you create a binary that relies on Cadmium and don't have that data directory it screws
<FromGitter>
... everything up, so the obvious solution would be to make the stop words a part of the binary for portability purposes.
<FromGitter>
<watzon> The only problem is how best to accomplish that. Any suggestions?
<FromGitter>
<j8r> we could compile our application with flags
<FromGitter>
<j8r> a flag to have english, another spanish, etc
ht_ has quit [Remote host closed the connection]
<FromGitter>
<j8r> like the venerable `./configure --with-curl --enable-static`
<FromGitter>
<Blacksmoke16> @bew new feature :slight_smile:
<FromGitter>
<Blacksmoke16> will be built into some assertions, namely the string ones. i.e. if you wanted to do `.strip` before checking size or something
<FromGitter>
<Blacksmoke16> make it like `#{DATA_DIR}en.txt`
<FromGitter>
<rmarronnier> Thanks :-)
<FromGitter>
<rmarronnier> now I get this :
<FromGitter>
<rmarronnier> `Error: Error opening file '\"/home/remy/crystal/masters/cadmium/src/cadmium/i18n/data/stopwords/\"en.txt' with mode 'r': No such file or directory`
<FromGitter>
<rmarronnier> Is this an escaping character problem ?
<FromGitter>
<rmarronnier> Where does the \ before en.txt comes from ?
<FromGitter>
<rmarronnier> Great !!!!
<FromGitter>
<rmarronnier> @Blacksmoke16 and @asterite : thanks so much, I'll get some sleep tonight :-p
<FromGitter>
<Blacksmoke16> np
<FromGitter>
<Blacksmoke16> hey @asterite do you happen to know if a new line is added to macros when they're expanded?
<FromGitter>
<Blacksmoke16> have a macro that defines a method, was trying to add doc comments above it to add to the default comments within the macro, but if you remove one or the other it works, but not both together
<FromGitter>
<Blacksmoke16> which would be caused by like
<FromGitter>
<jwoertink> How do y'all handle when you have 2 shards that have the same dependency, but each require a different version of that dep, and you need to use a specific one?
<FromGitter>
<jwoertink> and I want to use the "shard2" dep from master branch, but the dep from "shard1" is what's being loaded
<FromGitter>
<jwoertink> oh, look at that. If I flip the order of those two, it'll use the one I want
<FromGitter>
<jwoertink> neat
<FromGitter>
<Blacksmoke16> *doom*)
<FromGitter>
<asterite> Blacksmoke16 macros aren't really copy pasted into the program and then everything reparsed and so the comments are joined. If there's a comment on top of a macro call that comment will be copied to all nodes the macro generates, just ignoring the existing comments in the macro
<FromGitter>
<asterite> so an extra line or not doesn't matter in the current implementation
<FromGitter>
<Blacksmoke16> ah gotcha, thanks for the explanation