<FromGitter>
<schoening> Id like to add a big html warning block at the top of the crystal API pages when viewing an outdated version of the API, which has happened to me when getting there via a google search result. What repo do I need to fork?
akaiiro has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
akaiiro has quit [Remote host closed the connection]
<FromGitter>
<dscottboggs_gitlab> The documentation is automatically generated, and old versions may not be changeable retroactively. I'm not sure how they have it set up.
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
relyks has quit [Quit: relyks]
relyks has joined #crystal-lang
<FromGitter>
<schoening> That's why I was thinking doing a check via JavaScript is gonna be the simplest solution. Check the version number of the page and do an ajax request on what the current crystal version is. Then it does not matter if the pages are static. If possible we could do a one time re-build of all the pages, OR just add it to the newest ones and hope the old ones will get less and less visible by Google. Today google
<FromGitter>
... send me to version 0.24.1, for example.
relyks has quit [Remote host closed the connection]
devil_tux has joined #crystal-lang
rohitpaulk has joined #crystal-lang
t0nyandre has joined #crystal-lang
flaviodesousa has joined #crystal-lang
<FromGitter>
<swinSpo> Hi, can someone explain the "?" syntax to me? For types it means that the value can be nilable, but what about methods? I saw methods like "get?" which have this symbol
<FromGitter>
<ljuti> @swinSpo methods with “?” in their name usually follow the convention that the method will return a boolean
<FromGitter>
<swinSpo> oh really? I thought that they return the value or nil
<FromGitter>
<swinSpo> for example get(key) would return a value or raise an exception, while get? would return the value or nil
<FromGitter>
<ljuti> Oh, right
<FromGitter>
<ljuti> Yes, sometimes it’s used that way, too
<FromGitter>
<ljuti> But that’s just a convention AFAIK
<FromGitter>
<ljuti> Again, a matter of preference :) I usually use the latter definition for empty hashes
<FromGitter>
<Timbus> That syntax can't initialize it with anything, either
<FromGitter>
<Timbus> `thing = [1,2,3,4] of Float32`
<FromGitter>
<Prutheus> I have 2 classes, one called WORK::FINDER and the other HOME::FINDER ….. however, somewhere in my code i wanna have a variable called finder which gets the class object as value depending of a flag …. so how to declare my variable finder before the switch statement (for the flag) so it can get both classes as values?
<FromGitter>
<fusillicode_twitter> Basically I'm trying to use a general module that defines how objects are initialized and use it both directly and indirectly through another module
<FromGitter>
<fusillicode_twitter> Unfortunately I don't get an handle to the initialize method
<FromGitter>
<j8r> initialize can't be in a module, that's particular to classes/structs. This method allocates
<FromGitter>
<j8r> the only way is to use a macro, or you can have a `def initialize` and include a module with a `def self.new`
<FromGitter>
<fusillicode_twitter> @j8r ok that makes sense but I don't get the alternative of `def self.new`
<FromGitter>
<j8r> the fact is you need initialize in classes, it creates a `def self.new` with inside a GC.allocate or something like that. `def self.new` as is is like like all another class method - no GC allocation
<FromGitter>
<j8r> but the syntax will be the same, `Object.new`. You can then have a `new` inside `def self.new`
<FromGitter>
<fusillicode_twitter> and obviously thanks a lot for your support 🙇
<FromGitter>
<fusillicode_twitter> 🙇 🙇 🙇
<FromGitter>
<j8r> but you're right there are special names like `inherited`
<FromGitter>
<fusillicode_twitter> yeah I recall to have read something about macro hooks but unfortunately I never had any experience about them 😅
rohitpaulk has joined #crystal-lang
<FromGitter>
<proyb6> I realize Crystal home page should also advertise it's capable for writing code without rely on IDE, that should be a great point to attract newcomers as we all tends to see IDE as a powerful tools for writing complex projects
<FromGitter>
<proyb6> What do Crystal team think?
<FromGitter>
<proyb6> Perhaps ability to monitor memory and CPU usage on Crystal program is extreme useful
<FromGitter>
<swinSpo> Does crystal work on windows?
<FromGitter>
<swinSpo> Like can i crystal run app.cr and crystal build app.cr?
<FromGitter>
<fusillicode_twitter> totally agree with @proyb6
<FromGitter>
<fusillicode_twitter> from my humble point of view Crystal shines from the developer experience perspective
<FromGitter>
<proyb6> 👍 @fusillicode_twitter I have some idea why Meteor web framework who built a complex piece of code and their developers experience is to "reduce friction" as a powerful platform to work in, Crystal will need a similar kinds of platform for devs to feel belonging and ability to interact rapidly day and night
<FromGitter>
<proyb6> Perhaps need a github to discuss?
<FromGitter>
<proyb6> R
rohitpaulk has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter>
<j8r> that's not a github issue (related to code), more a google group thread to open
rohitpaulk has quit [Ping timeout: 250 seconds]
<FromGitter>
<cserb> What's the benefit of a Set over an Array in Crystal?
<FromGitter>
<j8r> A `Set`can only have an element once, an array hasn't this limit
<FromGitter>
<j8r> A `Set` is useful if you don't want duplicate elements
<FromGitter>
<cserb> This is clear from the docs, but is this the only reason to use a Set? It comes with limitations as well in that you can't do smth like `my_set[0]'
<FromGitter>
<bew> Well it doesn't make sense to have it, what's your usecase?
<FromGitter>
<proyb6> @j8r Agreed with Google Group but I don't think most of us know that channel.
moei has joined #crystal-lang
<FromGitter>
<cserb> @bew I have no usecase :) (yes it doesn't make sense to have it) I'd just like to understand better what a good usecase would be for a Set
<FromGitter>
<bew> Hmm if you want a list of all the unique words in a text, you can use a Set, try to add each word to it, and if the word is already in it it won't be added
<FromGitter>
<j8r> I do some devops, I've a list of packages to perform an action. I don't wan't to perform the action twice, so I've used a `Set`
<FromGitter>
<cserb> So the main benefit is not having to take care of duplicity like in an Array? I'd assume the Set checking for duplicity is also more efficient than in an Array?
<FromGitter>
<j8r> If I've used an Array I'll need an additional check with `.includes?` to not add a package twice
<FromGitter>
<j8r> yes, `includes` will re-traverse the `Array` one element after another
<FromGitter>
<cserb> Thanks for answering! This was my understanding as well, but thought that maybe I'm missing out on something
<FromGitter>
<ljuti> I can’t figure out how to bind the Contact object properly to the proc
<FromGitter>
<kingsleyh> Hi - is there anyone with C skills and Crystal skills who can work with me for a couple of hours over screensharing to help me make a shard of a hashing algorithm that’s written in C - it’s similar to scrypt-n - I can pay $50/hour for 5 hours help
<FromGitter>
<j8r> @ljuti Does the `Hash` are really dynamic? If not, you could pass a struct instead
<FromGitter>
<ljuti> @j8r The map can be a struct, just made a hash for the sake of simplicity
<Jenz>
If I want to analyze a crystal built executable, to find out what different parts of the stdlib takes the most place what do I need to read up about?
<Jenz>
(Hoping there's some expert hanging around)
<FromGitter>
<j8r> @ljuti and you want the from_node returns a result instead of nil?
<FromGitter>
<ljuti> I want a Contact object out of it
<FromGitter>
<j8r> Sorry I don't understand, the `pp obj1` returns a Contact object?
<FromGitter>
<ljuti> It does, but its attributes are nil
<FromGitter>
<ljuti> So what I’m asking is how to put the behavior I’ve laid out in main to be encapsulated inside the object
<FromGitter>
<ljuti> Node object comes from a parser/transformer that does validations. The map object defines which attributes to pull from the node and how to do it.
<FromGitter>
<ljuti> Originally I thought about extending `JSON::Serializable` but it was too cryptic for me :)
<FromGitter>
<Blacksmoke16> unless you want to read those arrays off the annotation, you could use that example, as the `BasicAssertion` handles no fields
<FromGitter>
<Blacksmoke16> but if you did want to read them off, would have to define your own initializer like in example above
<FromGitter>
<ljuti> OK, one more
<FromGitter>
<ljuti> If `foo`is bar, then `one` should have cat and mouse
<FromGitter>
<Blacksmoke16> hmm
<FromGitter>
<ljuti> If `foo` is `baz` then `one` shouldn’t be in the input and it should have field `two` with dog or bone
<FromGitter>
<ljuti> This should be doable, right?
<FromGitter>
<ljuti> So in that case property `one` must be set `nil` and then property `two` must have a value from the defined array
<FromGitter>
<Blacksmoke16> wow, i deff didnt think of this use case :p
<FromGitter>
<Blacksmoke16> but yea it prob should be doable?
<FromGitter>
<ljuti> I’ll try it out
Jenz has joined #crystal-lang
<FromGitter>
<Blacksmoke16> could do the custom assertion with a field of your other property, so that way you can read in the other property to have that to use in the assertion
<FromGitter>
<ljuti> Exactly
<FromGitter>
<Blacksmoke16> 👍 any issues let me know
<FromGitter>
<ljuti> 10-4
greengriminal has joined #crystal-lang
ua has joined #crystal-lang
akaiiro has joined #crystal-lang
<FromGitter>
<bararchy> @bcardiff you're here?
<FromGitter>
<Blacksmoke16> @ljuti am trying it out on my own side project, man am i liking it
<FromGitter>
<Blacksmoke16> slap on some annotations and done
<FromGitter>
<Blacksmoke16> much better than maintaining custom `.to_json` methods
<FromGitter>
<ljuti> Hear, hear
<FromGitter>
<Blacksmoke16> the other cool part, since it is built on top of `JSON::Serializable` you could still to `to_json` to serialize the whole obj
<FromGitter>
<Blacksmoke16> since it uses diff keywords
<FromGitter>
<Blacksmoke16> `@value : CrSerializer::Assertions::ALLDATATYPES` you dont need this because you're not reading a `value` key off the annotation
<FromGitter>
<Blacksmoke16> since you called yours `matchers`
<FromGitter>
<Blacksmoke16> i dont think that takes a string, should just be able to set the type of `matcher` as `Regex`
<FromGitter>
<ljuti> That’s what I tried first, then changed the matcher to be a string
<FromGitter>
<ljuti> If I return true straight away, it runs
<FromGitter>
<ljuti> So the problem is in the evaluation
<FromGitter>
<Blacksmoke16> try doing like `act.match(Regex.new(matcher))`
<FromGitter>
<Blacksmoke16> and since `matcher` is not nilable, can get rid of the `matcher : Actual...` and just do `@matcher` in the `Regex.new`
<FromGitter>
<Blacksmoke16> this reminds me...i thought i had a regex match assertion....
* FromGitter
* Blacksmoke16 adds that to the todo list
<FromGitter>
<vladfaust> Hi, got a new Job at crystaljobs. Cannot send e-mails to subscribers ATM, because campaign template isn't set up yet 😅
<FromGitter>
<vladfaust> Twitter postings are earsier though :)
<FromGitter>
<Blacksmoke16> @ljuti check the ending quote on your `"/\w+:(\/?\/?)[^\s]+/“` i dont think thats a proper double quote...it doesnt match the first
<FromGitter>
<bararchy> @vladfaust congratz\
<FromGitter>
<Blacksmoke16> OHHH @ljuti i know what the issue is
<FromGitter>
<vladfaust> Gonna need to optmize it for mobiles
<FromGitter>
<vladfaust> Yeah, thanks, @bararchy
<FromGitter>
<Blacksmoke16> but its super vague, compiler should deff have a better error message for it
<FromGitter>
<vladfaust> BTW that smarttrade guy confirmed on that he'd found a Crystal developer
<FromGitter>
<ljuti> Shouldn’t double-bang turn that into `Bool` though?
<FromGitter>
<kingsleyh> @vladfaust I'm sorry but I found posting a job quite hard - I can think of many improvements - I'm flat out working on other stuff though - but maybe when I get some time I will give you my feedback
<FromGitter>
<ljuti> Bingo, that does it
<FromGitter>
<vladfaust> Great, feedback is appreciated indeed
<FromGitter>
<vladfaust> I think that re-tweeting could drastically improve crystaljobs coverage
<FromGitter>
<vladfaust> Moving out of gitter-only-crystallers
<FromGitter>
<ljuti> @Blacksmoke16 This is really cool. Thanks for sharing!
<FromGitter>
<ljuti> Definitely useful for me
<FromGitter>
<Blacksmoke16> np, im going to see if i can narrow down that issue
<FromGitter>
<kingsleyh> Gitter is bridged with IRC as well - I only know of Gitter and IRC - but I guess there are other Crystal devs who don't use either of these
<FromGitter>
<Blacksmoke16> that error is super not helpful for something that could have been solved by like `return type expected Bool got RegexMatch?`
<FromGitter>
<Blacksmoke16> np :) glad someone other than me is enjoying it haha
<FromGitter>
<Blacksmoke16> but thanks for reminding me, ill add a regex match assertion
<FromGitter>
<kinxer> Is it possible to restrict a variable to be a subclass of a particular class AND to include a particular module? I know this can be done by introducing an intermediary (potentially abstract) class, but I'm wondering if there's another solution.
<FromGitter>
<kinxer> Also, I don't care if it's a proper subclass; as long as an "is a" relation holds between the variable and the class, it's fine.
<FromGitter>
<Blacksmoke16> but yea, something you could put on `age` property to say `make this obj invalid if any child assertions fail` would be a good feature
<FromGitter>
<ljuti> Uhhuh
<FromGitter>
<ljuti> I guess that could be done with a custom assertion?
<FromGitter>
<Blacksmoke16> hmm
<FromGitter>
<ljuti> Yeah, works. Default error message is just a bit cryptic but it can be customised, right?
<FromGitter>
<Blacksmoke16> yea, can just do `LessThan(message: "blah blah")`
<FromGitter>
<Blacksmoke16> each assertion has a `message` field that can be set
<FromGitter>
<j8r> does annotations are only meant to be used with macros?
<FromGitter>
<Blacksmoke16> afaik can only read them off annotations yea
<FromGitter>
<Blacksmoke16> wouldnt the easiest solution be to just do `include JSON::Serializable`
<FromGitter>
<ljuti> @Blacksmoke16 Yeah, I implemented just that :)
<FromGitter>
<Blacksmoke16> :p
<FromGitter>
<Blacksmoke16> it makes the assumption that child classes are validated *before* the parent, but that seems to be the case so works for me
<FromGitter>
<ljuti> Yeah, you’re correct. I have a spec which has valid data for parent object but invalid data for child object. Both parent and child are invalid and the error is the proper one.
return0e has quit [Read error: Connection reset by peer]
<FromGitter>
<Blacksmoke16> so it is an issue?
<FromGitter>
<ljuti> No, that’s the behaviour I want
<FromGitter>
<Blacksmoke16> 👌
<FromGitter>
<Blacksmoke16> writing some specs for it now
<FromGitter>
<j8r> @Blacksmoke16 no because you have to add an annotation for each ivar. I don't know if you have seen the `JSON::Serialization` implementation - it's rather complex
<FromGitter>
<Blacksmoke16> you dont *have* to
<FromGitter>
<Blacksmoke16> by default it serializes all ivars with they key as the name of the ivar
<FromGitter>
<Blacksmoke16> if you want to control they serialized key, or ignore a property then yea, would have to add some annotations
<FromGitter>
<j8r> The solution I've found is really simple, just use what you know and a macro defining the mapping. ⏎ I'll open an issue on it when I'm done with the implem for JSON. I already done one for CON
<FromGitter>
<j8r> it'll serialize only the keys defined in the mapping. 3 modes available, strict, lazy and full mapping
<FromGitter>
<jwoertink> Our app see this error message pretty often
<FromGitter>
<Blacksmoke16> i also set `assertions` as a getter on the `Validator` class, so can return an array of all the assertions set on the class if you wanted to do something more with it
<FromGitter>
<Blacksmoke16> would give you access to field, actual value etc
<FromGitter>
<mettuaditya> ohh thank you for the info
<FromGitter>
<Blacksmoke16> np
<Jenz>
Man, it ended draw
Jenz has quit [Ping timeout: 260 seconds]
hightower4 has quit [Ping timeout: 252 seconds]
sagax has joined #crystal-lang
<FromGitter>
<kinxer> I asked this a few days ago, but got no replies: does anyone know why I might be a "Permission Denied" error when trying to fetch from the Crystal dist repository from OpenSUSE?
<FromGitter>
<Blacksmoke16> :shrug:
<FromGitter>
<kinxer> I'm pretty sure I'm using the same repo as the instructions in the docs use for CentOS and RedHat. Is anyone using Crystal on those distributions with no issues updating?
<FromGitter>
<Blacksmoke16> @ljuti I pushed up a new branch for the `Valid` and `RegexMatch` assertions if you want to check them out
<FromGitter>
<Blacksmoke16> also includes that `invalid_properties` method
<FromGitter>
<jwoertink> My guess is it's missing some signed key
<FromGitter>
<jwoertink> Are you just trying to install crystal?
<FromGitter>
<jwoertink> You could try it from source, and then just report that error to the repo.
<FromGitter>
<kinxer> I have Crystal 0.26.1 from when I originally set up the repo, but my goal is to be able to update Crystal via my package manager.
<FromGitter>
<kinxer> How would I report the error to the repo?
<FromGitter>
<Prutheus> Are channels blocking? I mean when I do channel.send … does it wait for a receive until it continues?
<FromGitter>
<Prutheus> yes it is … okay, thanks
<FromGitter>
<Prutheus> I can use buffered channels
moei has quit [Quit: Leaving...]
thews has quit [Ping timeout: 250 seconds]
thews has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
t0nyandre has joined #crystal-lang
<t0nyandre>
I've been wondering; are there any active Discord communities for Crystal as well as the gitter/irc? :)
<FromGitter>
<vladfaust> Nope
<t0nyandre>
Fair enough xD
<FromGitter>
<vladfaust> I'm willing to create one as well as a discourse-based forum
<t0nyandre>
I'm just seeing people using Discord more and more so that's why I asked :) Ofc. I'd join if there was any but no need to create one just for us two ;P