ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.31.1 | 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
dwdv_ has quit [Ping timeout: 276 seconds]
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 276 seconds]
<raz> meh. going back to golang from crystal becomes increasingly painful. everything is so... awful. all i want is this little 5-liner. and in golang it explodes into 50 lines of nonsense.
<FromGitter> <tenebrousedge> that's what I don't like about Go
<FromGitter> <tenebrousedge> which is not to say that it doesn't have its advantages, but developer time is not among them
<raz> yes. i thought i like it for a while. the simplicity is tempting. but then you realize... you pay for it by repeating the same darn boilerplate over and over and over and over.
<raz> and once you start with crystal, all hope is lost for ever wanting to write golang again :(
<FromGitter> <tenebrousedge> I hope so :) I'd like to see Crystal replace golang. But it's an uphill battle
<raz> i doubt it can, with google backing golang. but i'm sure crystal will become one of the most popular languages soon. it hits so many sweet spots at once.
<raz> i can't get over how fast it is. i mean. i'm practically writing ruby here. minus the magic that always causes problems in ruby. but plus _other_ magic that is awfully convenient. and at the same time i have to never have to worry about performance in the slightest.
<FromGitter> <tenebrousedge> what are you writing, if I can ask?
<raz> a queue worker at the moment (fetch from SQS, do a bunch of API calls / processing, push to redis and SQS). nothing exciting. just one of the countless use-cases for which ruby is perfect but always a bit too slow, python too annoying (pyenv etc., ugh) and golang too rigid.
<FromGitter> <tenebrousedge> nice :)
<raz> yea. except for this golang portion. that i just decided i will port to crystal tomorrow as well. i'm getting sick of 'if err != nil' now. half of that friggin code is 'if err != nil'.
* FromGitter * tenebrousedge twitches
duane has joined #crystal-lang
<FromGitter> <Blacksmoke16> best way to join an array of arrays into one array?
<FromGitter> <tenebrousedge> `concat`?
<FromGitter> <tenebrousedge> oh, no
<FromGitter> <tenebrousedge> `flatten`
<FromGitter> <tenebrousedge> or `flat_map` if you need it
<FromGitter> <Blacksmoke16> there we go 😉
<FromGitter> <Blacksmoke16> thanks
<FromGitter> <tenebrousedge> np
hightower2 has quit [Ping timeout: 265 seconds]
duane has quit [Ping timeout: 250 seconds]
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Client Quit]
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo2 has joined #crystal-lang
duane has joined #crystal-lang
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 276 seconds]
alexherbo2 has quit [Ping timeout: 276 seconds]
snsei has joined #crystal-lang
return0e_ has quit [Ping timeout: 245 seconds]
return0e has joined #crystal-lang
ht_ has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
ht_ has quit [Quit: ht_]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<FromGitter> <bararchy> If I have a sigfault with the message: `corrupted size vs. prev_size` where should I be looking?
<FromGitter> <bararchy> also `malloc(): unsorted double linked list corrupted` :)
snsei has quit [Ping timeout: 276 seconds]
dwdv_ has joined #crystal-lang
<repo> maybe a race condition?
<repo> at least i had a unsorted double linked list corrupted error when i tried to use the same http client (with tls) from multiple threads
<repo> *an
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
hightower4 has joined #crystal-lang
alexherbo2 has joined #crystal-lang
snsei has joined #crystal-lang
alexherbo2 has quit [Quit: Ping timeout (120 seconds)]
alexherbo2 has joined #crystal-lang
<FromGitter> <bararchy> hmmmmmmmmm
<FromGitter> <bararchy> damn
<FromGitter> <bararchy> over channels? or just passing it around as shared mem?
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 265 seconds]
<FromGitter> <yxhuvud> could be you found something that isn't MT-secure.
<FromGitter> <bararchy> well, lately that's my expertise so XD
<hightower4> :)
snsei has quit [Ping timeout: 252 seconds]
<repo> blassin: over channels
<repo> sorry. barachy
<repo> sorry. bararchy
<FromGitter> <bararchy> hmmmmmmm
<FromGitter> <bararchy> nice
<FromGitter> <bararchy> so same usecase
<FromGitter> <bararchy> you remember against what Server\App it was running ?
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<FromGitter> <Daniel-Worrall> How do you guys feel like a compile flag for a lib to say whether it uses converters or not for the incoming data.
<FromGitter> <Daniel-Worrall> Like everything comes in as a string and is only guaranteed to be stringlike. I want the lib to be opinionated and make assumptions about the data in its format like int or date or whatever
<FromGitter> <Daniel-Worrall> Or should I have 2 separate classes and inherit and override
<FromGitter> <Daniel-Worrall> I'm thinking about it so users can use the non opinionated and be guaranteed their app won't throw errors if their api changes
<FromGitter> <straight-shoota> @Daniel-Worrall I don't follow. Could you describe an example?
<FromGitter> <Daniel-Worrall> Twitch API only guarantees string results in their API and reserve the right to change the format of the contents. If I were to make assumptions about the contents of their strings, it could break at twitches discretion.
<FromGitter> <Daniel-Worrall> I could either solve this by having a base class that doesn't convert and assumes exactly what they provide, then extend that class fot
<FromGitter> <Daniel-Worrall> For easy conversion for the user.
<FromGitter> <Daniel-Worrall> Or I could have macros that define which it uses depending on a compile flag in code or on build line
<FromGitter> <Daniel-Worrall> What are the opinions of using the latter
<FromGitter> <Daniel-Worrall> Sorry I can't really provide code example yet. Brainstorming on the move
f1refly has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 265 seconds]
duane has quit [Ping timeout: 265 seconds]
snsei has joined #crystal-lang
duane has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<FromGitter> <tenebrousedge> I wouldn't make it a build-time option. I would have an `API_VERSION` constant in the code, and only have one code path
<FromGitter> <tenebrousedge> if it's necessary to support multiple api versions, then this sounds like something to be handled at the version control level
duane has quit [Ping timeout: 240 seconds]
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <mavu> I'm trying to build crystal on raspberryPI (building after I cross compiled the compiler, and now want to build on the PI using that cross compiled compiler) and I get this message which seems weird to me, because I don't see how that would be incorrect. ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Any ideas? [https://gitter.im/crystal-lang/crystal?at=5dd69692d2c92c2275ce7050]
duane has joined #crystal-lang
<FromGitter> <mavu> Hmm, never mind. I had accidentially checked out 0.30.1 instead of 0.31.1
<FromGitter> <mavu> seems to compile now. Will report back in 2 hours or so when its finished :P
<FromGitter> <mavu> never mind, got this now: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dd698d39d72cd02b31c115a]
<FromGitter> <Daniel-Worrall> @tenebrousedge It's within the same API version as far as the request goes. The contents of the strings can change format whenever twitch decides, but if they start including letters in a field I assume is numbers, it will break my library, so I thought of offering a string only format, and a format that converts everything for you so you don't have to
<FromGitter> <Daniel-Worrall> I'll whip up some code to demonstrate now
<FromGitter> <tenebrousedge> That makes little sense. Is Twitch changing their API without a version bump, or does the API allow a broader set of data types than are used?
sagax has joined #crystal-lang
<FromGitter> <Daniel-Worrall> Their API specifies they will return a string. There has been a case in the past where they let emote ids (which were before just numbers in a string) to have suffixes such as "123456_bw" as modifiers to the emote. It wasn't a change of API version, there was just people that assumed that it would always be a number.
<FromGitter> <tenebrousedge> so it sounds like you should always interpret that as a string
<FromGitter> <Daniel-Worrall> So what I'm saying is I want the best of both worlds, to be able to have an API that doesn't break, but optionally give the user converters that may or may not work in the future, so it's their choice how they handle it
<FromGitter> <Daniel-Worrall> My actual question is how to implement it.
<FromGitter> <Daniel-Worrall> Whether I should have a flag that changes the return on a single class, or have 1 class inherit from the other
<FromGitter> <tenebrousedge> the latter is probably a better idea
<FromGitter> <Daniel-Worrall> You think the former is too confusing/ridiculous? :^)
<FromGitter> <tenebrousedge> it's unnecessary and overly complicated
<FromGitter> <igor-alexandrov> Hello. Can anybody explain me why there is no ```NamedTupleLiteral#merge``` method?
<FromGitter> <Daniel-Worrall> Because it's a macro method so it's a very simplified version
<FromGitter> <Daniel-Worrall> *macro Class
<FromGitter> <igor-alexandrov> I know, but is is technically possible?
<FromGitter> <Daniel-Worrall> Are you unable to replicate a merge with the given methods?
<FromGitter> <igor-alexandrov> I tried...
dostoyevsky has quit [Quit: leaving]
dostoyevsky has joined #crystal-lang
alexherbo2 has joined #crystal-lang
<FromGitter> <igor-alexandrov> https://play.crystal-lang.org/#/r/81y5 I have a code that loads plugin into class. What is need to do is to merge options passed to a plugin with options defined in `DEFAULT_OPTIONS` constant.
<FromGitter> <Blacksmoke16> its probably doable, just would have to be implemented
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
DTZUZO has quit [Ping timeout: 240 seconds]
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<FromGitter> <j8r> @igor-alexandrov what's your use case for `NameTuple`?
<FromGitter> <j8r> Perhaps it would be better to be a `struct`
<FromGitter> <firejox> @igor-alexandrov I would use hash to do for that.
<FromGitter> <j8r> Have you a sample of what you want to achieve?
<FromGitter> <Daniel-Worrall> Use a hash or ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dd6ac22f977187add8aacb1]
<FromGitter> <Daniel-Worrall> basically just replicated the NamedTuples#merge
<FromGitter> <igor-alexandrov> @j8r @firejox I am working on a plugin system for shrine.cr https://github.com/jetrockets/shrine.cr/blob/master/src/shrine.cr#L37 and I wanna to make `load_plugin` macro to accept options. Plugin itself can also have a default options, that should be merged during load.
<FromGitter> <j8r> 👍
<FromGitter> <j8r> @igor-alexandrov What about having `myplugin.load(options)`?
<FromGitter> <j8r> then, you could use the same logic as https://github.com/jetrockets/shrine.cr/blob/master/src/shrine.cr#L119
snsei has joined #crystal-lang
dwdv_ has quit [Quit: quit]
<FromGitter> <mavu> I just encountered a shard that contains binary libs. which means its only usable on one platform. Is that normal shard behaviour?
<hightower4> no
<FromGitter> <mavu> how would one differentiate platforms in shards? Is there a builtin mechanism? Or are shards supposed to just use system libraries instead of bringing their own bins.
<hightower4> assuming that the shard code doesn't compile on all platforms, there's a flag which is set by Crystal on every platform which can be tested from macro code
<hightower4> {% if flag? :linux %}, and there's a bunch of other flags (windows, unix, bits64, etc.)
snsei has quit [Ping timeout: 250 seconds]
<FromGitter> <Daniel-Worrall> `{% unless flag? :linux exit %}` :^)
<FromGitter> <mavu> I was trying to compile invidious on raspberypi, and it uses https://github.com/omarroth/lsquic.cr which happily installs ELF 64-bit libs it brings along on the PI. compiling works until the linker falls on its face.
<FromGitter> <Daniel-Worrall> pi is a second-class architecture so far
<FromGitter> <Daniel-Worrall> Not even the stdlib is guaranteed to work, nevermind shards :^0
<FromGitter> <Daniel-Worrall> :^)
<hightower4> yeah although distributing .a libs with shards is really strange
<FromGitter> <mavu> Well, i'm using crystal on it quite a bit, and it seems to work fine.
<FromGitter> <mavu> (fingers crossed)
phase858 has joined #crystal-lang
<FromGitter> <Daniel-Worrall> I came across a couple issues cross compiling the compiler, so I just cross-compile the apps instead
<FromGitter> <mavu> @Daniel-Worrall cross compiling the compiler works for me. never tried cross compiling the apps itself.
phase858 has quit [Quit: Leaving]
<FromGitter> <Daniel-Worrall> have you ran the specs?
ht_ has joined #crystal-lang
<FromGitter> <igor-alexandrov> @j8r plugin is a set of modules that extend different Shrine classes, so I want configuration to be stored on `Shrine` class
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 [Remote host closed the connection]
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 276 seconds]
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
alexherbo2 has joined #crystal-lang
<hightower4> mm, still at my "bunc of Procs with different signatures" issue
<hightower4> bunch*
<FromGitter> <tenebrousedge> try poking them with a stick
<hightower4> They're laying there like a pile of rocks, won't move
<hightower4> think I know. I have 3 types of data: bools, ints, and strings. The first two classes don't need a proc to wrap them at all, I can just read them directly.
<hightower4> The third category also in large majority of cases don't need a proc. However, not to have to deal with ones that do and don't, I'll probably just run all of them through a single method. This method might then also cache its results for further invocations (easy to do since return value is always String) and that's it
<hightower4> need to think about this
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
<FromGitter> <tenebrousedge> it sounds like you need an interface and several container objects that implement that interface
<hightower4> Any mockups on play to help me visualize?
snsei has joined #crystal-lang
<FromGitter> <tenebrousedge> well, say you have a `get_value` method, and implemented it with various classes that would deal with your different data types
<FromGitter> <tenebrousedge> and these would memoize the results as necessary, presumably using a `Hash`
<hightower4> Ah so... mm yeah I was thinking something along those lines now
<hightower4> Basically what I'm doing is I have a bunch of values (Bool, Int, or String). I can read them directly in large majority of cases. But some strings contain "%x" sequences, which indicate that the value can only be returned through a function.
<hightower4> Like "xyz" is just "xyz", but "xyz%p1%d" needs to become "xyz(value of first argument)" when the function is called
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
<hightower4> Yeah I'll take your suggestion tenebrousedge, thanks
alexherbo2 has quit [Ping timeout: 246 seconds]
alexherbo2 has joined #crystal-lang
<hightower4> Something like this, https://play.crystal-lang.org/#/r/81z3
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
alexherbo2 has joined #crystal-lang
<hightower4> but all of this is a simplification I realize. As soon as I make the Proc accept different type of arguments, like "Proc(Array(Int32 | String", it breaks apart
DTZUZO has joined #crystal-lang
sagax has quit [Quit: Konversation terminated!]
<FromGitter> <asterite> do you know the type of all things when you build the arguments list?
<FromGitter> <asterite> maybe another way... in `set_position` you are calling `Strings["cursor_position"]`. Why not using another constant to store that proc, or even a method definition, if you know what you need to call?
<hightower4> For the 2nd question, it all depends on my reading the definition file in runtime. If the file has a line like "cursor_position = "xyz%p1%d"", then from this I (1) know that cursor_position exist as a capability, (2) that its return type is string, and (3) with some playing around if needed, I could also parse the % chars to determine the number and type of arguments that are needed to call this
snsei has quit [Ping timeout: 265 seconds]
<hightower4> but it's all in runtime. Regarding types, I know that all types I'm working with are Bool, Int, String, but that doesn't help me much as that's 3 possible types, times a maximum arity of 9. So 3*9 = 27 possible combinations
<hightower4> or not even times but power-of
alexherbo2 has quit [Ping timeout: 276 seconds]
alexherbo2 has joined #crystal-lang
<FromGitter> <kinxer> Is there a way to inherit method documentation from a superclass?
<FromGitter> <Blacksmoke16> `# :inherit:`
<FromGitter> <kinxer> Excellent. I don't think that's in the docs; it probably should be.
<FromGitter> <kinxer> Thank you.
<FromGitter> <Blacksmoke16> reminds me i was going to make a PR to the book about that
<FromGitter> <Blacksmoke16> np
<hightower4> I think the solution I pasted above will work, because it appears the arguments can only be Ints
<hightower4> which makes that example with one/fixed type reasonable/usable
<hightower4> Thank you all for discussion
Human_G33k has quit [Read error: Connection reset by peer]
HumanG33k has joined #crystal-lang
<FromGitter> <rmarronnier> Hey all !
<FromGitter> <tenebrousedge> ohai
<FromGitter> <rmarronnier> Thursday night million dollars question : ⏎ What is a metaclass ?
<FromGitter> <rmarronnier> As is : `Error: @instance_vars are not yet allowed in metaclasses: use @@class_vars instead`
<FromGitter> <rmarronnier> *as in
<hightower4> rmarronnier you are in for a treat!
<FromGitter> <rmarronnier> I know abstract classes but never heard about meta class
<FromGitter> <rmarronnier> wooooo ! :-D
<FromGitter> <rmarronnier> > In object-oriented programming, a metaclass is a class whose instances are classes.
<FromGitter> <rmarronnier> Thanks wikipedia, but in my case it doesn't help me much...
<FromGitter> <kinxer> Do you have an example that results in that error?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dd6e3e7c4fca14de3c67c81]
<FromGitter> <rmarronnier> Seriously, I don't know how the following code can create an object which is a class : https://gist.github.com/rmarronnier/90aef3697ee7463a010b1196c632d8cc
<FromGitter> <rmarronnier> Line 26 is the offender
<FromGitter> <Blacksmoke16> i think the issue is you're using an ivar in a class method
<FromGitter> <Blacksmoke16> `@stop_words`
<FromGitter> <rmarronnier> ivar ? what is this creature ?
<hightower4> rmarronnier I think that description might be on the right track... looking into Crystal's code, it seems it calls parent classes and "class Class" itself metaclasses
<FromGitter> <Blacksmoke16> an instance variable, the one with the single `@`
<FromGitter> <rmarronnier> oh...
<FromGitter> <kinxer> Ah... That makes sense.
<FromGitter> <Blacksmoke16> ivars are tied to a specific instance of the obj, obs which a class method wouldnt have access to
<FromGitter> <kinxer> Also, side question: why are you including the `StopWords` module in your class? Is it designed to be used that way?
<FromGitter> <rmarronnier> It's a module which is used by several other classes / modules
<FromGitter> <kinxer> A'ight.
<FromGitter> <rmarronnier> @Blacksmoke16 : The thing is when I us @@stopwords, I get this `Error: instance variable '@stop_words' of Cadmium::PorterStemmer was not initialized directly in all of the 'initialize' methods, rendering it nilable. Indirect initialization is not supported.`
<FromGitter> <asterite> hightower4: what does each Proc end up doing in the end? Because I think here you just have `alias ArgType = Int32 | String | Whatever` and then you just have `Proc(Array(ArgType), ArgType)`. That is, it's all so dynamic that arguments come as an array of whatever type and the result if whatever type
<FromGitter> <asterite> then at runtime you check for args sizes and types
<FromGitter> <kinxer> Maybe `class_getter stop_words = @@@@loaded_stop_words[:en]`?
<FromGitter> <kinxer> Do other stemmers have an `initialize` or do they use class methods?
<FromGitter> <Blacksmoke16> ^
<FromGitter> <rmarronnier> There are no other stemmers for now
<FromGitter> <asterite> I think the error should be "class types can't have instance variables"
<FromGitter> <Blacksmoke16> idk enough about what is going on but it seems you're confusing instance and class variables
<FromGitter> <Blacksmoke16> and trying to use them both
<FromGitter> <Blacksmoke16> you can use class vars in instance methods but you cant use instance vars in class methods
<FromGitter> <asterite> or "can't use instance variables in class methods, like `def self.foo`"
<FromGitter> <rmarronnier> You're right, I'm really confused
<FromGitter> <kinxer> Okay, well do you want to do ⏎ ⏎ ```stemmer = PorterStemmer.new ⏎ stemmer.tokenize_and_stem( . . . )``` ⏎ ⏎ ? [https://gitter.im/crystal-lang/crystal?at=5dd6e585d2c92c2275d0d913]
<FromGitter> <rmarronnier> Stop me when I'm wrong :
<FromGitter> <rmarronnier> property blabla : String
<FromGitter> <rmarronnier> in `def initialize`
<FromGitter> <kinxer> No, not in `initialize`.
<FromGitter> <rmarronnier> @blabla = "cocacola"
<FromGitter> <kinxer> Oh, my bad.
<FromGitter> <rmarronnier> then
<hightower4> asterite yes, but what causes me problems is that if type is Proc(Array(Bool | Int | String)), and I call it with [1,2,3], it complains that I need to call it with Array(Bool | Int | String) and not with Array(Int). And even if I do [1,2,3].as(Array(Bool | Int | String)), it tells me it can't cast it
<hightower4> ah yes, I could define the argument to the function to be [] of ArgType
<FromGitter> <tenebrousedge> ^
<hightower4> ok anyway, will figure something out from here. Your help was very ample, so now need to do my part of the job, thanks.
<FromGitter> <tenebrousedge> or `Array(ArgType).new`
<FromGitter> <rmarronnier> ok, I won't pollute this cha more. I'll study the language ref
<FromGitter> <tenebrousedge> I don't like the `[] of Type` syntax
<FromGitter> <rmarronnier> thanks for your help anyway :-)
<hightower4> tenebrousedge right, right, agreed, those were just ad-hoc examples for the chat
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
alexherbo2 has joined #crystal-lang
<FromGitter> <Blacksmoke16> @rmarronnier essentially the difference is instance vars are tied to an instance of a class while class vars to tied to the type, let me make a simple example
<hightower4> Btw, tenebrousedge my issue of arg type not matching comes from the fact that I wanted to avoid calling functions with [args], I wanted just args. So I define functions to accept (*args), which when I call it with only ints and then do #to_a, produces Array(Int) rather than Array(ArgType). And I can't cast this from one type to another using #as
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/81z7
<FromGitter> <Blacksmoke16> is prob the better explaination
<hightower4> tenebrousedge so for now I'll avoid the whole issue by just simplifying the type to be just Int32, since I seem to see that only ints are ever used as arguments.
<FromGitter> <tenebrousedge> o.o wotay
<FromGitter> <phase858> I'm probably missing something obvious from the docs, but is there a way to get full path to an aplications binary easily and not the working directory?
<FromGitter> <kinxer> @rmarronnier To add on to @Blacksmoke16's example: https://play.crystal-lang.org/#/r/81z8
<FromGitter> <asterite> hightower4 the args can be a splat, like `*args`, then you can do `args.map(&.as(ArgType)).to_a` and pass that to the proc
<hightower4> Nice one!
<FromGitter> <tenebrousedge> *FILE* references the full path to the currently executing crystal file. @phase858
<FromGitter> <tenebrousedge> `__FILE__`
<FromGitter> <phase858> @tenebrousedge thanks
<FromGitter> <kinxer> @tenebrousedge That doesn't work for the binary.
<FromGitter> <tenebrousedge> there's another one for the binary I think
<hightower4> If it's not, one possibly non-portable way phase858 is to check where symlink /proc/0/exe points to
<FromGitter> <phase858> I'll take a look at that
<FromGitter> <Blacksmoke16> `PROGRAM_NAME`
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/81z9
<FromGitter> <kinxer> Could you combine `Dir.pwd` with `PROGRAM_NAME`?
<FromGitter> <Blacksmoke16> could just be how the playground works in why it returns the full path tho
<hightower4> PROGRAM_NAME seems to give full path
<FromGitter> <kinxer> Yeah, `PROGRAM_NAME` only returns what you'd get in Bash with `$0`.
Yxhuvud has joined #crystal-lang
<FromGitter> <Blacksmoke16> ```./test ⏎ "./test"``` [https://gitter.im/crystal-lang/crystal?at=5dd6e9c9c4fca14de3c6ab52]
<FromGitter> <Blacksmoke16> yea with it built its diff
<hightower4> Maybe use File.expand_path to get a full path in all cases
<FromGitter> <Blacksmoke16> `File.expand_path PROGRAM_NAME` would do it ye
<FromGitter> <phase858> ``File.expand_path PROGRAM_NAME`` worked
<FromGitter> <kinxer> Excellent.
<FromGitter> <Blacksmoke16> 👍
<hightower4> phase88: Assuming that you don't chdir somewhere else inbetween starting a program and calling File.expand_path
<FromGitter> <phase858> that would probably have had isses since this a thing that gets called by links so starts in other directories, but needs to load a config that with the binary
<FromGitter> <kinxer> Yeah. Luckily, as long as you store your initial working directory before changing directories and use that as the second argument to `File.expand_path`, it should work.
<hightower4> phase858 yes, as kinxer says just save this value as first thing when program starts
<FromGitter> <asterite> @phase858 There's also `Process.executable_path` which might be more robust
<FromGitter> <asterite> probably what you are looking for
<hightower4> ah, ++
<FromGitter> <kinxer> Oh, excellent.
<FromGitter> <phase858> ``Process.executable_path`` looks a bit more elegant for my use too since I had to go up a dir too
<hightower4> without a doubt it's the way to go
<hightower4> Is there a defined-or operator in Crystal? Like in Perl I'd do $var //= 1; this would set var to 1 only if var was nil
<hightower4> and/or what's the shortest syntax to do this
<FromGitter> <tenebrousedge> `||=`
<hightower4> yes but this sets value if value is false
<hightower4> I only want to set if value is nil
<FromGitter> <tenebrousedge> `nil` is also falsey
<hightower4> yes but I want narrower, not wider condition
<hightower4> I want false ||= true to remain false, which with ||= it wouldn't and with //= it would
<FromGitter> <tenebrousedge> `x = y if if z.nil?`
alexherbo27 has joined #crystal-lang
alexherbo27 has quit [Client Quit]
alexherbo2 has quit [Ping timeout: 240 seconds]
<hightower4> right, x = y if x.nil? , that'd be it if there is no shorter way to write it
<FromGitter> <kinxer> I think `x = y if x.nil?` is probably the clearest way to write it.
<FromGitter> <kinxer> And I don't know of a shorter way.
<FromGitter> <dwdv> While we're at it: we don't have something similar to ruby's symbol param syntax as in `[1,2,3].inject :+ # => 6`, do we?
<FromGitter> <tenebrousedge> `reduce` has some specific overrides
<FromGitter> <tenebrousedge> in Ruby
<FromGitter> <tenebrousedge> `reduce` does not work with arbitrary symbolic arguments like that
<FromGitter> <kinxer> @dwdv Is there something specific you're trying to do?
<FromGitter> <tenebrousedge> Crystal has `&.` syntax
<FromGitter> <tenebrousedge> as well as `&->`
<FromGitter> <dwdv> Alright, thanks. Yeah, symbols are choking with map et al. Should have checked.
alexherbo2 has joined #crystal-lang
<FromGitter> <asterite> `[1, 2, 3].sum` (probably `+` and `*` are the most common cases and we have shortcuts that are easier than in Ruby)
<FromGitter> <asterite> `[1, 2, 3].sum`
<FromGitter> <dwdv> Yes, thanks, I know of these, just wanted to check whether there is a shorter way of writing these.
<FromGitter> <asterite> well, `sum` is shorter than `inject &:+` :-)
<FromGitter> <tenebrousedge> Ruby also has `sum` though
<FromGitter> <kinxer> It's also a whole lot easier to read.
<FromGitter> <asterite> Oh, I forgot about that
alexherbo2 is now known as alex```
<hightower4> One thing I do miss in the language are 'and' and 'or'. The syntax is so much polished that it almost looks like natural language, and then you have the || and && sticking out
snsei has joined #crystal-lang
ht_ has quit [Quit: ht_]
Xeago_ has joined #crystal-lang
Flipez9 has joined #crystal-lang
Xeago has quit [Read error: Connection reset by peer]
Flipez has quit [Quit: Ping timeout (120 seconds)]
CommanderViral has quit [Quit: ZNC 1.7.1+deb1+bionic1 - https://znc.in]
Xeago_ is now known as Xeago
<FromGitter> <christopherzimmerman> My new favorite C library (https://sod.pixlab.io/index.html). I was trying to find an OpenCV API that would integrate with Crystal but this one is fantastic.
<hightower4> great. opencv is a such a mess :)
<FromGitter> <christopherzimmerman> Took half an hour to write the Crystal library, another half to get it to work natively with NDArrays, so I'm very close to having scipy.ndimage (https://docs.scipy.org/doc/scipy/reference/ndimage.html) in Bottle
snsei has quit [Ping timeout: 240 seconds]
<FromGitter> <bararchy> @christopherzimmerman amazing!
<FromGitter> <bararchy> that's really cool
<FromGitter> <igor-alexandrov> @j8r finally I made it work as it should: https://play.crystal-lang.org/#/r/81zk ⏎ ⏎ Now I can do the following: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dd7058f99dfe74c9583f17e]
<hightower4> ehm, why if I have "def x(name, *arg); someproc.call arg.to_a" it tells me No overload matches Proc(Array(Int16), String) with type Array(NoReturn) ?
<hightower4> arg.to_a is for some reason being Array(NoReturn)
<FromGitter> <tenebrousedge> hightower4, it works for me https://play.crystal-lang.org/#/r/81zn
<hightower4> yeah in isolated case it works...
<hightower4> need to look into it more
<FromGitter> <tenebrousedge> hightower, you looked at the NoReturn docs? https://crystal-lang.org/reference/syntax_and_semantics/return_types.html
<FromGitter> <tenebrousedge> also https://play.crystal-lang.org/#/r/81zo
<FromGitter> <tenebrousedge> ^ you do need to pass a second arg
<FromGitter> <rmarronnier> @Blacksmoke16 @kinxer : Thanks for the tips, got out for a while , looking at your examples right now
<hightower4> tenebrousedge right, and I don't see the source of the error.
<FromGitter> <tenebrousedge> well, somewhere you're calling your method without a second arg
<FromGitter> <tenebrousedge> so grep for `x([^,]+)`
<FromGitter> <tenebrousedge> `x\([^,]+\)`
<hightower4> yes but arg.to_a should expand to empty array []
<hightower4> if no args are given
<FromGitter> <tenebrousedge> yes but not `Array(Int16)`
<hightower4> ah indeed
<hightower4> yes but my issue is that it gives this same error even if I beforehand test for arg.size > 0
Jenz has joined #crystal-lang
<hightower4> I'll check if Asterite's suggestion with a map above would work
<FromGitter> <tenebrousedge> https://play.crystal-lang.org/#/r/8203
<hightower4> that worked, thanks
<FromGitter> <tenebrousedge> np
<Jenz> Anyone know of a site with ideas or recommendations for programming projects
<Jenz> -?
<FromGitter> <tenebrousedge> there's a list of wanted Crystal libraries, if you like
<hightower4> https://github.com/crystal-community/crystal-libraries-needed would appear to be that list
<Jenz> Thanks, tenebrousedge, hightower4
<hightower4> christopherzimmerman in this list of wanted modules they mention wanting numpy, scipy, and tensorflow. Maybe you could mention your module in those issues
<FromGitter> <kinxer> @christopherzimmerman (just to ping you)
<FromGitter> <Daniel-Worrall> Hmm can files be required conditionally by macro?
<Jenz> Daniel-Worral, yes
<hightower4> you can begin/catch require's.. at least in Ruby
<Jenz> hightower4: This is not Ruby, you can't dynamically require
<hightower4> ah of course, yeah, macro then
<Jenz> {% if some_cond %} require "my_lib" {% end %}
<FromGitter> <watzon> Yep. But `some_cond` has to be known at compile time is the only catch.
<FromGitter> <christopherzimmerman> Thanks for linking the needed libraries, just commented on a couple of the issues. As much as I would love to implement tensorflow at some point, I don't think I could ever work on ML outside of work, would be too much to handle :P
<Jenz> Bottle looks nice, christopherzimmerman
Jenz has quit [Ping timeout: 265 seconds]
duane has quit [Ping timeout: 265 seconds]
<FromGitter> <christopherzimmerman> Appreciate it! Been a ton of fun learning crystal and working on it.
alex``` has quit [Quit: The Lounge - https://thelounge.chat]
snsei has joined #crystal-lang
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo2 has joined #crystal-lang
<FromGitter> <Blacksmoke16> i need a better way to handle DI in a web framework context, and i cant think of any ideas :/
<FromGitter> <Blacksmoke16> tl;dr i need a way to make it so all "services" are initialized for each request and each request should have a diff instance of the container/services
<FromGitter> <Blacksmoke16> or maybe take a step back and reevaluate how it should work
snsei has quit [Ping timeout: 240 seconds]