ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Crystal 0.23.1 | Fund Crystal's development: | GH: | Docs: | API: | Gitter:
<watzon> Is there any way to avoid creating a whole class for nested objects using JSON.mapping?
<watzon> For instance I have an object that has a nested object called `metadata` that only has one field
<watzon> It would be kinda nice not to have to create a `Metadata` class with only one field
<hightower4> Why isn't "string".gsub /s(.)/, $1 working?
<FromGitter> <maiha_twitter> watzon: I'm glad if this helps you.
<watzon> maiha_twitter that's pretty nice. Can it be a drop in replacement for JSON.mapping?
<FromGitter> <maiha_twitter> watzon: Yep. I'm using only `Jq.mapping`. But it has poor implements than `JSON.mapping` for performance. Please test in you environment :)
<watzon> maiha_twitter I'm trying it right now, can you not just use `Array(Class)` outside of a tuple? I'm getting an error when I try
<FromGitter> <maiha_twitter> Yep, it would be a issue of macro. Please declare with tuple format.
<watzon> maiha_twitter would it be possible to make it automatically create the tuple if one is not provided? For instance, `words: Array(Word)` would get turned into `words: {Array(Word), ".words[]"}`
<watzon> Great shard though btw, I feel like this should be the native behavior of JSON.mapping
<FromGitter> <maiha_twitter> Right! I'd like to support it when I have a change.
<watzon> maiha_twitter that would pretty much make it perfect in my humble opinion
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 joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
snsei_ has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<FromGitter> <decal> Oh cool there's an IRC bridge bot? :-) Is that for FreeNode #crystal-lang?
_whitelogger has joined #crystal-lang
<FromGitter> <codenoid> yup @decal
<watzon> Ok, is there a way that anyone knows of to avoid this particular pyramid problem when trying to get a deeply nested object?
<FromGitter> <codenoid> how ? , note : just for myself ;)
<FromGitter> <codenoid> wait, where's the original cr tshirt image,,
<FromGitter> <codenoid> crystal site text too big
rohitpaulk has joined #crystal-lang
martinium has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<watzon> maiha_twitter it would also be nice if you could use `#[]` on a class that uses Jq in the same way that you can if you do ``
<watzon> To do that I guess classes that use `Jq.mapping` would have to inherit from `Jq`
martinium has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rohitpaulk has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
latemus has joined #crystal-lang
latemus has left #crystal-lang [#crystal-lang]
DTZUZO has joined #crystal-lang
<FromGitter> <faustinoaq> > crystal site text too big ⏎ ⏎ @codenoid Maybe you can remove `https://` ⏎ ⏎ Like amber []
rohitpaulk has quit [Ping timeout: 248 seconds]
_whitelogger has joined #crystal-lang
alex`` has joined #crystal-lang
<FromGitter> <ansarizafar> Is anyone using mruby ?
_whitelogger has joined #crystal-lang
Groogy has quit [Read error: Connection reset by peer]
<FromGitter> <unreadable> Idts
DTZUZO has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
Groogy_ is now known as Groogy
<Groogy> Morning!
alex`` has quit [Quit: WeeChat 1.9.1]
<FromGitter> <Papierkorb> Morning
Papierkorb_ has joined #crystal-lang
claudiuinberlin has joined #crystal-lang
alex`` has joined #crystal-lang
<Groogy> haha it's time for Norovirus outbreaks in Sweden again, it's always funny to see the company go essentially in "Zombie lockdown mode" this time of year
<txdv> wat
<txdv> everyone knows that a vampire will kill the entire world
<FromGitter> <ansarizafar> Humans are capable enough to destroy the world. No vampire needed.
mark_66 has joined #crystal-lang
<FromGitter> <iambudi> > > crystal site text too big ⏎ ⏎ @codenoid Maybe you can remove `https://` ⏎ ⏎ Like amber ... []
<FromGitter> <iambudi> And what font is that?
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
<FromGitter> <unreadable> Morning all
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
alex`` has quit [Ping timeout: 258 seconds]
<FromGitter> <unreadable> Have you ever had struggles choosing between learning Go or C#? Don't worry, they got you covered by introducing the new go. (dot) engine backed by Microsoft boom
<FromGitter> <unreadable> Jk, bored on the train..
<FromGitter> <unreadable> Jokes aside, they got a nice small donation of $24k which is pretty nice
<FromGitter> <unreadable> From Microsoft ofc
<FromGitter> <petoem> good morning
<FromGitter> <unreadable> Sup
<txdv> godot has nothing to do with go
<FromGitter> <unreadable> And the joke has failed, I should stop
<FromGitter> <petoem> the joke aside, C# support for godot is cool ⏎ this will certainly attract new developers
<FromGitter> <yxhuvud> Groogy, de har that in our office for the last month. So much colds :(
<Groogy> We have tons of expats
<Groogy> and they get freaked out by not understanding the Swedes fear at this point of the year :D
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Papierkorb_> Groogy: out of curiosity, do you know if security is actually of any concern for the multiplayer network guys on games?
<FromGitter> <yxhuvud> wow that sentence of me. bloody spellchecker.
<FromGitter> <bararchy> Papierkorb_ Interesting question
<Papierkorb_> Well whenever someone looked into one the results were plain awful. but maybe you only hear about the fails?
<FromGitter> <bararchy> I guess games are less of an attack target, as the game server is a single entity and not spread across the web having multiple users and companies hosting it, so a more interesting attack target is , lets say, common http server, or dns server, and less a closed source specific game server hosted at company X, also I guess it's harder to attack because of "security by obscurity" . ⏎ ⏎ Maybe it's more of
<FromGitter> ... a target for cheaters and people who want to hack the game itself
<FromGitter> <bararchy> this logic fails though when talking about open-source or wildly used servers like counter strike , or minecraft etc.. where lots of people host those servers
<FromGitter> <bararchy> and indeed those kind of games do get attention
<Papierkorb_> > as the game server is a single entity and not spread across the web having multiple users and companies hosting it
<Papierkorb_> There are many companies specialized in hosting gaming servers, they're thriving. A bug would hit them hard.
<Papierkorb_> But you not only have the gaming server, but also the game (client) itself. If you can do RCE here, well gaming Hardware is quite powerful, sounds great to smuggle in a coin miner
<Papierkorb_> Also consider UDP probes many game servers use to get session data from a server (used in a server browser).
<Papierkorb_> You know DNS reflection attacks? Yeah, same principle. Ask ID about Quake3 lawl.
<Groogy> Papierkorb_ how do you mean like security for a game?
<Papierkorb_> Groogy: If the networking component (The part actually doing the socket handling packet parsing) is hardened.
<Groogy> eh you mean between clients or you mean like with server structure?
<Papierkorb_> Between the Game client and the publicly facing gaming server
<FromGitter> <Rinkana> Morning :)!
<Groogy> no idea, never worked with that
<Groogy> We used to have a match making server ages ago but we shut it down since it didn't actually work. I doubt it had any kind of protection at all
<Groogy> now days we just use Steam's connection managers for NAT punch through, etc. We don't even have an IP adress to another client
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Client Quit]
claudiuinberlin has joined #crystal-lang
<FromGitter> <sdogruyol> steam is interesting itself
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <faustinoaq> > Nice. Got a high res amber logo i could use to print on something? ⏎ >> And what font is that? ⏎ ⏎ @iambudi check []
<FromGitter> ... AUrz--GQF9nrXfdfy-vFrfb2nGq9wwr6lG5bXby8HL2YEhFH2dHKh1inh2oXEg
<FromGitter> <bararchy> Seems like there isn't much compared to how much the game is known
<FromGitter> ... EdYVul8p7TkcYxKdYfJlt7ONyu05LmeAcvCBc8xdBe4MA27Nf4vKhXaHzGSvq0kUdkWovJOnNf-v7-M3tsV
<FromGitter> <bararchy> I really wish 0.24 will be out already :\
<crystal-gh> [crystal] MakeNowJust opened pull request #5166: Semantic: don't guess ivar type from argument after assigned (master...fix/crystal/not-guess-argument-type-after-assigned)
<FromGitter> <sdogruyol> @bararchy you're not alone :)
<FromGitter> <bararchy> I need stuff from master but multiple shards I use won't support latest changes
<FromGitter> <bararchy> haha
<FromGitter> <bararchy> I usually patch manually
gcds has joined #crystal-lang
<FromGitter> <sdogruyol> ugh, that's tough
<gcds> Is there a way to have a function with different code for different platforms?
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 258 seconds]
claudiuinberlin has joined #crystal-lang
devil_tux has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<gcds> ahm could someone help me with binding writing? :D
<gcds> how I could define this kind of thing in Lib section? extern const mach_port_t kIOMasterPortDefault;
<Papierkorb_> `$kIOMasterPortDefault : MachPortT`
<gcds> thanks
<FromGitter> <sdogruyol> I really think @Papierkorb and @oprypin should write a "C binding cookbook" 💯
<FromGitter> <sdogruyol> you guys have lots of applied knowledge
<Papierkorb_> sdogruyol, My answer would really just be "Use bindgen"
<Papierkorb_> There's enough arcane stuff that you really don't want to do manually
<gcds> i use crystal_lib but it does not work completly well so I was just asking :D
<Papierkorb_> And some deity help you if what you do is platform specific, or you need to find a path to your lib(s) manually.
<Papierkorb_> Though global variables isn
<Papierkorb_> isn't in bindgen yet *hides*
<gcds> yeah its platform specific MacOSX IOKit framework :D
<Papierkorb_> That's not too bad. I was referring to multi-platform libs offering some platform-specific API
<gcds> no no, I am doing serialport shit... Mac with its own api to list serial ports :D
<gcds> starts to get fun :D Error in src/ argument 'matching' of 'IOKit#service_get_matching_services' must be IOKit::CfDictionaryRef, not IOKit::CfMutableDictionaryRef
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Client Quit]
<gcds> ahm how I can change that global variable name because it cant link it
<Papierkorb_> I'd try `$new_name = original_name : Restriction`
<gcds> yeah it worked :D
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 246 seconds]
rumenzu has joined #crystal-lang
claudiuinberlin has joined #crystal-lang
<gcds> ahm I need another help :D I have function with arg const char* I defined as UInt8* as documentation suggested
<gcds> but now I get error 'IOKit#cf_string_make_constant_string' must be Pointer(UInt8), not Pointer(String)
<gcds> nvm idiot me :D
<FromGitter> <faustinoaq> Interesting
<FromGitter> <sdogruyol> what's this?
<FromGitter> <faustinoaq> Just a software I saw in University in Science Faculty. I just had curiosity about the "Crystal" name. 😅
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 258 seconds]
<gcds> Papierkorb_ Could help me once more? I have an argument in binding Uint8* which is basically char * in c. What I need to pass to it get aka string back? now I just wrote out buffer and it returns number instead
<Papierkorb_> Use : UInt8*, ...)
<gcds> u mean pass out buffer to ?
<Papierkorb_> no pointerof
<gcds> hmm but for some reason buffer is not Uint8* but just simple Uint8
<Papierkorb_> then it's not a string
<FromGitter> <bew> don't use `out` here
<Papierkorb_> Besides me not liking `out` at all, it should be fine there.
<Papierkorb_> gcds: is that the actual `fun` line?
<gcds> yes
<gcds> then I get undefined local variable
<Papierkorb_> that should break. No idea what a `Boolean` is either.
<Papierkorb_> I only know of `Bool`
<Papierkorb_> The arguments are missing names.
<gcds> alias Boolean = UInt8
<Papierkorb_> ...Why?
<gcds> dont ask me... I used to generate with crystal_lib
<Papierkorb_> And crystal_lib generated that fun line?
<gcds> ahn no this I just coppied from header
<FromGitter> <bew> Papierkorb_ do you see an issue with the fun?
<gcds> original from header looks like this
<gcds> Boolean CFStringGetCString(CFStringRef theString, char *buffer, CFIndex bufferSize, CFStringEncoding encoding);
<Papierkorb_> bew, missing argument names
<Papierkorb_> Yeah that'll horribly break with `out`. You have to allocate space first, and then tell it how big it is
<gcds> ahm so something like create new string and the pass pointer?
<Papierkorb_> create a buffer, pass that, create string from buffer
<gcds> buffer?
<Papierkorb_> I think you might want to read up on C
<Papierkorb_> the issue isn't that I couldn't tell you, but that there's so much more. You'd end up with a flaky wrapper. Fixing a crashy wrapper later on is much harder than writing it correctly from the get-go.
<FromGitter> <bew> gcds, you can create a buffer with `buffer =` then pass it to the fun like: `the_func(cf_str_ref, buffer, buffer.size, encoding)`
<FromGitter> <bew> Papierkorb true
<gcds> Papierkorb_ yes I know, but I am beginner with Crystal and I am still learning. I know some of C enough to get things done, if something doesnt work I try to figure out. But for e.g. Crystal is not so big on resources like C in the internet
<gcds> bew: thanks it worked. I tried to use IO::Memory but it did not worked out as I wanted :)
<Papierkorb_> A buffer in Crystal is the same concept as in C
<gcds> I understand but I was thinking u mean some kind of module Buffer thats why I was asking
DTZUZO has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
<gcds> Is there a quicker way to filter out 0 from buffer than this? path[0, path.index(0).as(Int32)]
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
<Papierkorb_> there's probably (hopefully) a string size function in that IOKit stuff. ask that, size the buffer according to it
<gcds> its file path
<gcds> max size can be LibC::PATH_MAX
<Papierkorb_> So? Is this a different function from before?
<gcds> ahh I understood
<gcds> Sorry I was copying code from existing library and after ur message I understood that I was dumbly following the code without thinking outside box
<FromGitter> <bew> there might be a CFStringGetLength
<gcds> yeah
<gcds> got it working :D
<gcds> ports # => [/dev/cu.usbmodem142121"]
snsei has joined #crystal-lang
rohitpaulk has joined #crystal-lang
snsei has quit [Ping timeout: 252 seconds]
rohitpaulk has quit [Ping timeout: 252 seconds]
z64 has quit [Quit: WeeChat 1.9]
<FromGitter> <ansarizafar> @faustinoaq How can we access nested Hash value?
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
<FromGitter> <bew> @ansarizafar you mean, in general in crystal? or in a specific context known only by faustinoaq ?
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
<FromGitter> <ansarizafar> Here is a nested Hash. ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ How can I access user_id? I thought faustinoaq is available that's why I mentioned him []
<FromGitter> <GrgDev> What is the Crystal equivalent of determining what methods a module has? I am trying to port some Ruby code that uses a `#defined?` call and I am trying to figure out the equivalent in Crystal since I didn't see that method in the docs
<Papierkorb_> GrgDev, There's no direct equivalent. You could use macro code for that, but you'd check first if that code ports over well.
<Papierkorb_> #defined? should check if a constant is defined. It's possible, but you shouldn't.
<Papierkorb_> Ruby paradigms, especially those for meta programming, do *not* translate well. Another popular thing is `#send`, which we don't have either (by choice)
<FromGitter> <bew> @ansarizafar how did you get that hash? if you know the type of the nested hash, I think you'd need to do `the_hash["user"].as(TypeOfNestedHash)` and use the result from there
<FromGitter> <bew> if you got it from JSON, you should look at JSON.mapping to avoid having to deal with a hash
<FromGitter> <ansarizafar> @bew Hash(String, JSON::Type) it's payload of JWT token
<FromGitter> <GrgDev> But the macro would be a check at compile time instead of runtime. Hmmmm... I'll have to think about this differently. The issue has to do with trying to port a Ruby tokenizer library that seems to be language sensitive and there's a check for "Does the currently loaded language module have X feature" before calling it in case it is not defined in that language. I guess I could just throw in a hack right now
<FromGitter> ... where all modules have a common boolean constant for that feature being asked for.
noblehelm has joined #crystal-lang
<FromGitter> <bew> what kind of "language feature" are you talking about? @GrgDev
<FromGitter> <iambudi> > How can I access user_id? I thought faustinoaq is available that's why I mentioned him ⏎ ⏎ @ansarizafar if you know the nested type data, you can do this ⏎ ⏎ ```user_id = the_hash["user"].as(Hash(String, Int32 | String)).["user_id"];``` []
<Papierkorb_> GrgDev, What logic is not there at compile time can never exist at runtie
<Papierkorb_> GrgDev, that sounds exactly like something that doesn't translate well at all
Papierkorb_ has quit [Quit: Konversation terminated!]
<FromGitter> <ansarizafar> @iambudi It's not working
<FromGitter> <ziprandom> hey crystalers, hows it going?
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
snsei has quit [Remote host closed the connection]
<FromGitter> <GrgDev> Papierkorb_ Here's the specific example I was looking at earlier related to that.
snsei has joined #crystal-lang
<FromGitter> <ziprandom> been experimenting with go and concurrency (of which I have only a rudimentary understanding), and after checking out go's channels I'm asking myself whether the difference between crystal and go atm. is that go can run the routines that it spawns on different physical processors while crystal can't. because the channel api looks pretty similar ..
snsei has quit [Remote host closed the connection]
<FromGitter> <iambudi> @ansarizafar
<FromGitter> <bew> hey @ziprandom it's been a while!
snsei has joined #crystal-lang
<FromGitter> <GrgDev> Here a reference to a language module is being passed in and seeing if the SingleQuotes feature in the language is defined. If yes, use that feature. If not, fall back to the common language module's SingleQuotes feature
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<FromGitter> <ziprandom> @bew doesn't mean I have not been checking github/crystal, crystalshards and crystal-ann every day though!
<FromGitter> <GrgDev> However, what language is being passed in here is determined by what language the client selects at runtime.
<noblehelm> is there a easy way to discover the type of a variable/object?
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<FromGitter> <bew> ahah ! yes Cr fibers are heavily inspired from Go's, and true parallelism is missing currently :/
snsei has quit [Remote host closed the connection]
<FromGitter> <ziprandom> @noblehelm:
<FromGitter> <bew> noblehelm like: `puts typeof(somevar)` ?
<FromGitter> <GrgDev> Parallelism might be missing but that doesn't change that they are much easier than other concurrency design patterns (supposedly, never used them myself yet).
<FromGitter> <ziprandom> @bew so implementing this shouldn't change the api a lot ..
<FromGitter> <bew> noblehelm: typeof is the compile-time type known by the compiler, class is the runtime type
<FromGitter> <GrgDev> Which can return different things, especially in the case of Nil-able variables
<FromGitter> <bew> @ziprandom that's what I think too, but it changes how the fibers are run, and it poses issues of thread-safe-ness I think
snsei has joined #crystal-lang
<FromGitter> <ziprandom> @GrgDev Channels and true parallelism do not exclude each other. go can run threads in true parallel by just changing a runtime configuration setting
snsei has quit [Remote host closed the connection]
<FromGitter> <GrgDev> I thought fibers were more or less the equivalent of lightweight green threads?
claudiuinberlin has joined #crystal-lang
<FromGitter> <ziprandom> @bew true
<FromGitter> <GrgDev> Like Ruby back in the 1.8 days where it ran on a single native thread
<FromGitter> <ziprandom> does ruby have parallelization now?
<noblehelm> Thank you
<FromGitter> <GrgDev> At some point they started allowing the spawning of new native threads to pair with the green threads
<FromGitter> <GrgDev> Not exactly sure when
<FromGitter> <GrgDev> Also not sure if it is a 1 to 1 ratio
<FromGitter> <GrgDev> I just dug up this article saying that it was Ruby 1.9 that got native threads but still doesn't have parallelism because of the Global Interpreter Lock
<jsn-> MRI isn't the only ruby, though; jruby had real threads for ages
<crystal-gh> [crystal] tbrand opened pull request #5167: Added .DS_Store into template/gitignore.ecr (master...master)
<FromGitter> <GrgDev> It actually specifically notes that in the footnote at the bottom of the article
<FromGitter> <GrgDev> Although the footnote just says that JRuby is a completely different situation and does not go into the details of it.
<gcds> is there an easy way to convert string to StaticArray(UInt8, *) ?
thefynx has left #crystal-lang ["WeeChat 1.7.1"]
DTZUZO has quit [Ping timeout: 248 seconds]
<FromGitter> <bew> gcds why do you need that?
<FromGitter> <bew> you shouldn't have to do this, unless you have no other option or you're using a lib binding imo
<gcds> argument LibC::Char[128] :( or I maybe I am doing something wrong
<crystal-gh> [crystal] RX14 closed pull request #5156: Detect recursive structs through tuples, named tuples and recursive aliases (master...bug/recursive-struct)
<FromGitter> <bew> where do you need that? in a lib binding?
<gcds> yes
<FromGitter> <bew> I think you can simply use it as if it was `LibC::Char*`, and just pass the string to it! Papierkorb_ you around? WDYT?
devil_tux has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <bew> gcds can you share the C function prototype?
<gcds> sure a moment
<gcds> CFTypeRef IORegistryEntrySearchCFProperty(io_registry_entry_t entry, const io_name_t plane, CFStringRef key, CFAllocatorRef allocator, IOOptionBits options)
<gcds> its io_name_t plane
<gcds> searching now for its definition
<gcds> omg apple... :D
<FromGitter> <bew> ahahahahaaah x)
<gcds> typedefchario_name_t[128];
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Client Quit]
<gcds> I am feeling like I am repairing car engine through exhaust pipe :D
<noblehelm> is there any difference between spec's be and eq?
<FromGitter> <ziprandom> noblehelm:
rumenzu has quit []
<FromGitter> <ziprandom> eql uses == to check if to objects are equivalent by their values (or however == is implemented of the two objects) while be checks, if it is the same object (same object id)
<noblehelm> oh, i see, i totally forgot about everything as an object
<FromGitter> <asterite> Ñ
<FromGitter> <ansarizafar> @bew Strange error ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Is it a crystal bug? []
<FromGitter> <paulcsmith> One thing I love about Elixir is that it makes it easy to add helpful errors like this or this The awesome thing about crystal is that it catches a lot of this at compile time, the
<FromGitter> ... problem is that sometimes it's not clear to the user how to correct the problem. What would you all think about have some kind of macro that allows you to specify compile time errors for methods?
<FromGitter> <paulcsmith> I'm thinking something like this: Where you can define compile time errors that are triggered if no method with the right types match.
<FromGitter> <paulcsmith> It could raise the normal compile time error, along with the custom error message underneath to help guide the user to a solution. I think this would be the kind of thing that REALLY makes people love a language or framework. Feels a bit more human and can help guide newer people to a solution more quickly
<Papierkorb> `{{ raise }}`
<Papierkorb> So, already exists
<FromGitter> <paulcsmith> It doesn't allow you to do what I've shown as far as I know
<Papierkorb> not in its entirety. but it's a start for most.
<FromGitter> <paulcsmith> It's a start, but the possibilities are a lot more limited
<FromGitter> <paulcsmith> You can't raise based on return type for example
<Papierkorb> you could also spam the user through method_missing, which I wouldn't like much if I saw that
<Papierkorb> mh?
<FromGitter> <paulcsmith> And you need to make things into macros that may not need to be
<crystal-gh> [crystal] RX14 closed pull request #5167: Added .DS_Store into template/gitignore.ecr (master...master)
<Papierkorb> ..huh?
claudiuinberlin has joined #crystal-lang
<Papierkorb> Have you actually tried it?
<FromGitter> <paulcsmith> I mean you can't use `{{ raise }}` in a normal method right
<Papierkorb> That'd be news to me
<FromGitter> <paulcsmith> You have to make it into a macro
<Papierkorb> Seems you know more than me
<RX14> you can't raise on return type
<RX14> because macros run before typing
<Papierkorb> On return type not, but what's the point in that?
<RX14> but you can use {{raise}} in a normal method
<Papierkorb> If you want to restrict what can be returned ... use a restriction
<Papierkorb> If someone doesn't understand what that is about, they wouldn't understand your error message either.
<Papierkorb> Or rather, such person wouldn't read either error message.
<FromGitter> <paulcsmith> Yes, but raise doesn't work for this:
<FromGitter> <paulcsmith> I don't see how you can raise a message at compile time if the type is wrong
<RX14> uhh
<Papierkorb> Why would you want that? Just use a Restriction?
<RX14> name : String
<RX14> thats literally how
<Papierkorb> ^
<FromGitter> <paulcsmith> Yes, I get it, but sometimes it's not as clear what the expected argument is
<FromGitter> <paulcsmith> Like in the redirect example
<FromGitter> <paulcsmith> And there is an example there where the return type is used to help the user figure out what to do
DTZUZO has joined #crystal-lang
<FromGitter> <paulcsmith> Maybe you guys are just really smart, but I've seen plenty of people see a type error, but not know what to do to get it working
<FromGitter> <paulcsmith> A helpful error message to nudge people in the right direction is really helpful
<Papierkorb> Not know what to do? What have they tried?
<RX14> @paulcsmith what redirect example?
<RX14> im not sure by what you eman by return type anyway?
<Yxhuvud> There are times when I've seen places where giving specialized error messages for cases like this would be nice. Connecting a type given in one place to a type in a different place can sometimes be unintuitive.
<FromGitter> <paulcsmith> It has a number of examples
<Papierkorb> I don't see how that redirect sample isn't just a {{raise}} away?
<RX14> i don't see what the point of that is anyway
<RX14> you can't guide a person through every way they can screw up using your library
<RX14> and nor should you
<FromGitter> <paulcsmith> @Papierkorb because you can't match the type in a macro like that
<FromGitter> <paulcsmith> I believe it is helpful
<FromGitter> <paulcsmith> Actually I know it is
<FromGitter> <paulcsmith> People love Elm because it gives people these hints
<FromGitter> <paulcsmith> It doesn't just tell you what went wrong, it helps you figure out how to fix it
<RX14> surely this would be better done as improvements to the compiler error messages in general
<FromGitter> <paulcsmith> And the redirect example is a bit contrived, but the other two are not. People have trouble figuring out why the return type is nil when they forget an else
<FromGitter> <paulcsmith> Not necessarily.
<RX14> instead of duplicating the work again and again
<Papierkorb> If you'd listen, much of that is already possible. e.g. that compile_error thing there, yep, possible.
<RX14> and with ugly syntax
<Papierkorb> Just use an inherited hook checking for that
<travis-ci> crystal-lang/crystal#07d50be (master - Detect recursive structs through tuples, named tuples and recursive aliases (#5156)): The build passed.
<DeBot_> (Detect recursive structs through tuples, named tuples and recursive aliases)
<RX14> just def a redirect(_location, status : Int32)
<RX14> and use {{raise}} in it
<RX14> it's much cleaner Papierkorb
<Papierkorb> If people don't understand a type restriction, they should really learn the language.
<RX14> ^
<FromGitter> <paulcsmith> RX14: I like that. I didn't realize you could do that
<Papierkorb> RX14: Was talking about the `call doesn't return nil` thing
<RX14> yeah
<RX14> you can do that too
<FromGitter> <paulcsmith> How would you do that?
<FromGitter> <paulcsmith> I like the example of using raise with a type restriction. That's cool and I hadn't thought of that
<RX14> <Papierkorb> Just use an inherited hook checking for that
<Papierkorb> ‎[17:59] ‎<‎Papierkorb‎>‎ Just use an inherited hook checking for that
<FromGitter> <paulcsmith> I don't get how you would do that?
<Papierkorb> Korbian law in effect again. Whatever you type, no one's gonna read it anyway.
<FromGitter> <paulcsmith> > If people don't understand a type restriction, they should really learn the language
<FromGitter> <paulcsmith> I disagree with this
<Papierkorb> ... the heck?
<FromGitter> <paulcsmith> They may get what the compiler is saying, but not know how to fix it
<Papierkorb> If it's so easy to fix, why doesn't your API account for it?
<FromGitter> <paulcsmith> SO if it says "You need to return a LuckyWeb::Response" they may not know how to do that if they aren't familiar with the framework. An error message saying "use render or redirect" would be helpful
<Papierkorb> If it's not automatically fixable, why don't your docs mention it?
<RX14> if your readme/docs don't mention this they suck
<FromGitter> <paulcsmith> I think we're talking past each other. Of course they *can* read docs and guides, but if they can see a solution right in the error message
<RX14> and if you dont read the docs then what can you do
<FromGitter> <paulcsmith> You guys come off very negatively
<FromGitter> <paulcsmith> There are better ways to speak to people
<Papierkorb> paulcsmith, people who don't want to learn the language, and don't want to read docs, why would they read error messages?
<FromGitter> <paulcsmith> This is a false dichotomy. Some people don't remember every single thing they read in the docs, or get confused by the error message. Helping people is good
<Papierkorb> Really now? You want something, we showed you alternatives on how to actually achieve much of that with already existing features.
<FromGitter> <paulcsmith> Elm has proved this. Look at the number of people that talk about how much they love their error messages
<RX14> well
<FromGitter> <paulcsmith> > if your readme/docs don't mention this they suck
<RX14> does elm have user-defined error messages
<Yxhuvud> Good error messages will give hints enough to go look up the correct things in the docs. bad errors won't.
<RX14> or is it just the compiler has fantastic error messages
<FromGitter> <paulcsmith> No but Elixir has them and people find them super helpful. I already linked to a few in Elixir that do this
<RX14> elixir has them? all i saw was raises
<RX14> isn't that runtime?
<FromGitter> <paulcsmith> Yeah, but it's solving the same problem. Helping users figure out why they're getting an error
<Papierkorb> ... it's not solving the same problem
<Papierkorb> I mean, there's runtime raise
<RX14> not at all lol
<RX14> exactly
<FromGitter> <paulcsmith> It is. It's helping people figure out what they need to change
<FromGitter> <paulcsmith> It totally is
<RX14> but we have runtime raises too?
<Papierkorb> What are you ranting about right now?
<Papierkorb> I don't get it.
<RX14> they're different features which can be used in different ways to achieve the same goal @paulcsmith
<Yxhuvud> runtime raises doesn't help people fix compile errors.
<RX14> that's what we're saying
<Papierkorb> We even showed you how to do much of what you want.
<FromGitter> <paulcsmith> Yes, I'd like to do what Elixir does, but at compile time
<FromGitter> <paulcsmith> Yeah I get it
<Papierkorb> You can do it already?
<FromGitter> <paulcsmith> Thank you. I'm just saying that it is useful. Trying not to feel like such a dumbass
<FromGitter> <paulcsmith> I think this is useful and I feel like you guys think I'm an idiot for wanting to help user's fix their errors :P
<Papierkorb> DUDE
<Papierkorb> You're not even reading what we're telling
<Papierkorb> What's the point?
<FromGitter> <paulcsmith> What have I not understood? I get what you've said and I'm grateful. I will use the type restriction and raise to give helpful feedback errors
<FromGitter> <paulcsmith> Isn't that what you're saying?
<FromGitter> <paulcsmith> I didn't realize you could do that. I'm glad you showed me how.
<Papierkorb> What's the issue then
<RX14> I can't see much misunderstanding here either Papierkorb
<FromGitter> <paulcsmith> I still don't understand how to do that with inherited hooks or whatever though
<Yxhuvud> paulsmith: I bet papierkorb and rx14 is the kind of people that are happy with the error messages openssl output. They *are* documented after all. But it is utterly impossible to find that documentation from googling the error message.
<Papierkorb> Me neither
<Papierkorb> But thanks for telling me what I think
<RX14> i'm all for improving the compiler's error output
<RX14> elm is a fantastic guide on that
<FromGitter> <paulcsmith> Agreed. Super nice 😄
<Papierkorb> I mean, you could like, open a RFC issue on GH?
<RX14> RFC for what?
<Papierkorb> For whatever they want
<RX14> there's not much more concrete
<FromGitter> <paulcsmith> RX14: I'm a bit dense here, how would you raise an error if the returned type is wrong
<FromGitter> <paulcsmith> I get how to raise helpful error messages with arguments, but not return type :S
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <paulcsmith> And I'm super stoked that a lot of this can be done with no changes to the language!! I'll write a blog post on this once I get it all figured out so other's can give it a shot too :D
<RX14> you should write a shard
<RX14> which provides a helpful macro for raising when people implement the wrong return type on an abstract method
<FromGitter> <paulcsmith> I'd love to! I'm just not sure where to start on it :S
<RX14> id need to have a play to figure out the details
<FromGitter> <paulcsmith> Any pointers?
<RX14> the basic gist is to define a macro included/extended/whatever hook
<RX14> and then in the hook use @type and find the method you want in @type.methods
mark_66 has quit [Remote host closed the connection]
<RX14> hmm maybe its not possible Papierkorb
<RX14> even if the macro is run after typing im not sure if the return type of methods is a thing
<RX14> because we never see the "detail" of all the different possible instantiations
<RX14> so there's no way to expose it when there's multiple input args
<RX14> and therefore no way to get the return type
<RX14> @paulcsmith you're likely to have to do runtime checks for abstract methods return types
<RX14> but thats very rare I fnd
<RX14> i can see this being useful in something like rails
<RX14> where you find a lot of newcomers
<RX14> but its a lot of work
<FromGitter> <paulcsmith> RX14: Thanks for looking into it. I also couldn't figure out a way to do it at compile time
<FromGitter> <sdogruyol> elm and rust doing a great job at compile errors
claudiuinberlin has joined #crystal-lang
<crystal-gh> [crystal] luislavena opened pull request #5168: Honor no-color option from `spec` command (master...pass-spec-no-color-option)
<Papierkorb> RX14: will have a look later
<FromGitter> <paulcsmith> I can't do at runtime since it's caught at compile time. Which is nice because it will prevent an error. I was just hoping I could help guide users a little more. But it's something they'll just have to figure out for now haha
<RX14> @paulcsmith so just remove the return type spec from the abstract method def?
<RX14> it'll not not compile
<FromGitter> <paulcsmith> I'll definitely add some stuff using the type restricted method and `{{ raise }}`. Thanks for the help on that guys
<FromGitter> <paulcsmith> RX14: I'm not sure I understand the "not not compile". What do you mean?
<FromGitter> <paulcsmith> @sdogruyol Yeah it's really nice. I've got some ideas to help improve the error messages. One was to change the order of macro output
<Yxhuvud> rx14: likely that will only move the issue to somewhere later where a method is called upon the method. That is likely to be even worse for the user compared to a compiler error in their own code.
<FromGitter> <paulcsmith> This is a huge stumbling blog for people I've worked with because they expect the code they wrote to be last, but sadly I think I didn't explain it well
<RX14> no
<FromGitter> <sdogruyol> no? for what?
<Yxhuvud> (second method -> return value)
<RX14> Yxhuvud, the idea is to remove the method return annotation and replace it with a runtime raise
<RX14> using unless ret.is_a?(ExpectedType); raise "..."; end
<FromGitter> <paulcsmith> I'd rather get compile time than runtime if I had to choose. Even if it meant a less specific error. BUT maybe I could do something else. Whipping up a gist now
<RX14> if that method is called in multiple places just wrap it in a helper method which does that check
<RX14> @paulcsmith sure but thats not possible right now
<FromGitter> <paulcsmith> Yeah totally. Sorry for being unclear. Was just thinking out loud :)
<FromGitter> <paulcsmith> I think the helper method might do the trick. Trying to figure out how to get that working now and will post here if it works, in case someone is interested
<FromGitter> <paulcsmith> Works!
<FromGitter> <paulcsmith> A bit roundabout, but it works. This is awesome. Thanks for the pointers RX14. I really appreciate it 😄
<Yxhuvud> That is actually really nice.
<FromGitter> <paulcsmith> Best of all worlds. Get a compile time error, and a custom message 👍 Woo hoo And with no changes to the language. That's awesome. I love how powerful Crystal is and it's not even 1.0
<FromGitter> <sdogruyol> @paulcsmith how's the reaction at thoughtbot? I'M curious to hear how a Ruby shop reacts to Crystal
<FromGitter> <paulcsmith> One downside is the error doesn't point to the `Action#call` line, but that's probably not a big deal. Tradeoffs I suppose
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <paulcsmith> @sdogruyol It's a bit mixed. The few that I've paired with have enjoyed it. The errors for macros were a big turnoff: and because a lot of people are using Elm and have been spoiled :P
<FromGitter> <paulcsmith> They liked the type system. Formatter was a huge plus. Macros were nice. Speed was nice of course
<FromGitter> <sdogruyol> ah yeah :P
<FromGitter> <paulcsmith> I think one hurdle is getting over the Ruby syntax. It was super easy for them to pick up, but it makes it feel less "new" I thought that myself, but once I used it more I fell in love
<FromGitter> <paulcsmith> But yeah error messages (mostly for macros), and lack of a console of some kind are the main impediments right now
<FromGitter> <paulcsmith> Oh and how to handle nils bites people a bit (when to use try, when to assign to a local var), but once people get it it becomes less of an issue
<FromGitter> <sdogruyol> yeah
<FromGitter> <vonKingsley> @sdogruyol a while ago you were promoting the state of crystal survey, was that just promotion or were you running that survey?
<FromGitter> <paulcsmith> I'm excited to see the results of that :D
gcds has quit [Ping timeout: 248 seconds]
<FromGitter> <GrgDev> @bew & gcds: I actually got an apple dev that I am friends with to explain why that thing exists the way it does
<FromGitter> <GrgDev> For context: He said "We don’t have fixed-size stack arrays, so as a temporary fix we import them as tuples which are binary compatible. It’s also impossible to unsafely access past its memory. "
<FromGitter> <bew> he means, in swift?
alex`` has joined #crystal-lang
<FromGitter> <GrgDev> In that IOKit
<FromGitter> <bew> yes but "We don’t have fixed-size stack arrays" is for Swift I think
<FromGitter> <GrgDev> I could ask. I literally just sent him the definition link asking "Why?"
<FromGitter> <bew> the link you sent is part of the Swift documentation, no need to ask him IMO ^^
claudiuinberlin has joined #crystal-lang
<FromGitter> <GrgDev> Okay, good, I just don't know anything iOS so I was hoping to not have to add any context
<FromGitter> <Rinkana> I see that IO does not have a `seek` method. Is the preferred method to do ``` ⏎ io.rewind ⏎ io.skip([bytes]) ⏎ ⏎ `````` []
<FromGitter> <bew> note: not all IOs can rewind or seek
<FromGitter> <Rinkana> I know it's a file in this case. So i know it at least has `#rewind`
<FromGitter> <bew> if it's a file, `IO::FileDescriptor` has `seek` so just use that, no?
<FromGitter> <Rinkana> Hmm you're right. No idea how i read over that
noblehelm has quit [Quit: Lost terminal]
Groogy2 has joined #crystal-lang
<FromGitter> <GrgDev> So, in this Ruby code I am porting to Crystal, I came across `gsub!(/:/o, ' :'.freeze)` and, correct me if I am wrong, but in this scenario, the `/o` at the end of that regex does absolutely nothing
claudiuinberlin has quit [Quit: Textual IRC Client:]
<FromGitter> <bew> according to it has sth to do with interpolation
<FromGitter> <bew> no idea what he was trying to do here, as I don't see any interpolation..
<FromGitter> <GrgDev> Exactly
<FromGitter> <GrgDev> I am wondering if the regexs just got sprinkled with `/o`s in the hope of a performance increase
<FromGitter> <GrgDev> I usually like to assume that I just don't know better when I come across stuff like this, buuuuuuut...
<FromGitter> <sdogruyol> @vonKingsley running, I'm actually waiting for some input from manas team
<FromGitter> <sdogruyol> the survey is over
hightower3 has joined #crystal-lang
hightower4 has quit [Ping timeout: 255 seconds]
rohitpaulk has quit [Ping timeout: 255 seconds]
gcds has joined #crystal-lang
<FromGitter> <pnloyd> Is something like, ⏎ ⏎ ```puts [1,2,3,4,5].reduce do |a, e| ⏎ a + e ⏎ end``` ⏎ ⏎ possible? []
<FromGitter> <pnloyd> Ya I see that you can do that
<FromGitter> <pnloyd> I suppose I'm specifically asking if you can directly make puts accept the result of the reduce expression.
<Papierkorb> Or just use braces
<FromGitter> <pnloyd> O'k so that is what I want to do. I tried `puts (expression that uses block)` and that failed. ⏎ So is there a specific reason `puts (simple expression)` works and `puts (expression that uses block)`. And then you remove space between `puts` and `expr` then is magically works with block.
<FromGitter> <pnloyd> I'm only worried because I just want to understand what is going on behind the scenes.
<FromGitter> <pnloyd> This is just making me feel like I'm missing something 😟
<Papierkorb> pnloyd, do .. end gets attached to the outer-most call (that's "puts" in your case), braces attach to the most-recent call ("just to the left")
<FromGitter> <pnloyd> @Papierkorb, shoot I remember reading that in the docs, slipped my mind. Thanks.
<Papierkorb> Yeah that's a bit confusing at first when learning Ruby and/or Crystal
<FromGitter> <pnloyd> Ya Iv'e never even heard of the concept of blocks before. At first I was like, "no, I want lambda expressions and for item in collection do loops". But I'm quickly getting used to it.
<oprypin> you never really get used to id
<Papierkorb> the thing that's interesting about blocks is not that they're a new concept (Anonymous functions/closures/lambdas are nothing new). It's how they're incorporated into the language, which make their feel so much different that it actually changes API design decisions
<oprypin> t
<oprypin> (in a negative way)
<Papierkorb> mh?
<FromGitter> <pnloyd> I think re-branding Procs as lambda expressions would be more familiar to people coming from many other languages. Or maybe communicating in the docs it's a similar concept.
<Papierkorb> `Proc` is the name Ruby uses, and that's where we copied it from
<FromGitter> <pnloyd> Since I associated Proc as something that has to to with interop with C it sounded scary to me at first.
<FromGitter> <pnloyd> Ahh I see
devil_tux has joined #crystal-lang
<Yxhuvud> papierkorb: ruby has both procs and lambdas though
<Papierkorb> They're all instances of `Proc`
<Papierkorb> lambda{ } and proc{ } have a hair-thin semantic difference that I actually forgot what it was
<Papierkorb> Not to mention stabby lambda. Though I mostly used it cause I think the name is just great lul.
<Papierkorb> ah right, the behaviour of `return` was different in Ruby
claudiuinberlin has joined #crystal-lang
<FromGitter> <splattael> Papierkorb, Ruby's lambdas also check their arity
<FromGitter> <unreadable> Wouldn't be better that the `initialize` keyword to be replaced `init`?
<FromGitter> <unreadable> with*
<oprypin> unreadable, yes, it would. was discussed and rejected.
<FromGitter> <unreadable> whyyy
<FromGitter> <unreadable> or maybe not `init`, but `initialize` feels ugly even than the good old `constructor`
<Papierkorb> ... why?
<FromGitter> <unreadable> why did they reject it?
<FromGitter> <unreadable> I know there would be some major breaking changes though..
<Papierkorb> I don't see the issue?
<FromGitter> <unreadable> let me guess, ruby uses initialize as well, right?
<Papierkorb> Typing it is no problem, every non-utterly-stupid editor will auto-complete it after typing it once
<FromGitter> <unreadable> I'll solve it quickly with a snippet
<Papierkorb> Almost every editor supports snippets too
<FromGitter> <unreadable> nvm
<FromGitter> <unreadable> yup
<Papierkorb> And what RX14 says in the comments, it's an (ugly) abbreviation
<gcds> I have question regarding multiple same function definitions. If I have like 10 different ways to call a function if I want to add a block feature I should duplicate all of those calls?
<oprypin> yes
<gcds> fck..
<oprypin> gcds, but that's just two
<oprypin> maybe all those 10 different ways dont have to be duplicated
<oprypin> why don't you type it all out and then i'll try to shorten it
<RX14> if the block is always the same
<RX14> just use *args passthrough
<Papierkorb> gcds: If you can't combine the methods otherwise (Remember, we have union types), and you want to support both yielding and non-yielding, yes-but-mostly-no. If you have methods like `def foo(bar : String, handler : Proc)`, you can have a single `def foo(bar : T, &handler : Proc(T, Nil)) forall T; foo(bar, handler); end`
<RX14> also yes named args really help cut down on dupes
<Papierkorb> Of course depending on your exact use-case, but you get the gist
<Yxhuvud> another option is to have the block version be the main versions and have the non block version call it with empty block
<gcds> this that I have... I want to make available block style like HTTP::Server to call a block with io which is returned by open and itself and also be available by normal
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Papierkorb> datCamelCasedProperty
<oprypin> that's java
<oprypin> gcds, there are default arguments
<gcds> yes
<gcds> sorry for camelCase I write in daily job in camelCase and writing in underscore style just kills me :D
<oprypin> dataBits : Int32 = 8 etc
<Papierkorb> Just set those as default argument values in the .open methods
<gcds> oh so you can skip default?
<Papierkorb> then use keyword arguments to set only those you want
<Papierkorb> This isn't java, yes we have good default support
<gcds> can be last argument block and be optional?
<Papierkorb> no
<gcds> ahh
claudiuinberlin has joined #crystal-lang
<gcds> i removed those methods and left one with default values
<gcds> so now I should create another one which has block?
<Papierkorb> yes by passing-through all arguments, yielding, and then closing (or whatever thermology serial ports use) in an ensure
<gcds> ok
<Papierkorb> I don't really like your .new, what's up with that?
<Papierkorb> Why isn't a #initialize sufficient?
<gcds> ah it was play around with those optional parameters i will fix iti
<gcds> it*
<gcds> this code looks clean compared with my try with implementing Mac IOKit features to receive a list of available ports :D
<FromGitter> <unreadable> That BaudRate enum though lol
<gcds> I dont know what else todo I need to have a list of valid baudrates or etc... Plus later on I have to check if its standard or not...
<Papierkorb> You can allow the user pass in an Int32 for convenience, then use `BaudRate.from_value?` to check if it's allowed
<Papierkorb> That, or have a Constant array of allowed baudrates, and then just check if it's #includes?() the users given rate
<gcds> here is my disaster pile...
<Papierkorb> useless returns
<gcds> mm?
<Papierkorb> the last expression in a body is that code bodys result, no explicit `return` required
<gcds> yeah I know, just old habit...
<gcds> this stuff will need someone review to make maybe nicer... I was head breaking to get this stuff working I am 100% sure there is better ways to do some things than I though
<Papierkorb> no idea what dataBits is, but that looks like it wanted to be a @[Flags] enum
<Papierkorb> Oh not a flags enum, but an enum
<Papierkorb> Line 45, `when` cases don't fall-through in Crystal. You probably meant `when 1, 2`
devil_tux has quit [Ping timeout: 240 seconds]
<gcds> aha
<gcds> atleast communications works :D
alex`` has quit [Ping timeout: 255 seconds]
gcds has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gcds has joined #crystal-lang
devil_tux has joined #crystal-lang
<FromGitter> <unreadable> Will this get approved?
<FromGitter> <unreadable> or not
gcds has quit [Client Quit]
<FromGitter> <sdogruyol> noone knows for sure
<Papierkorb> Who knows. No one in who voted in favor actually bothered to write a comment. Some people who initially voted in favor first actually removed their vote later on. And a 5 "nay" to 7 "yay" isn't really a strong signal either
<RX14> i doubt it
<RX14> i'll fight it
<RX14> and ary seems to be the only one stringly for it
<FromGitter> <unreadable> Also, why are there over 300 issues open? Shouldn't them automatically close after a period of time
<FromGitter> <unreadable> ..
<RX14> only 300?
<RX14> hah
<RX14> thats good
<RX14> rust has nearly 3k
<RX14> go has over 3k
<RX14> nim has over 1k
<RX14> we're doing gooood
<RX14> thats one thing ary's good at
<RX14> closing unneccesary issues
<FromGitter> <unreadable> gj ary, whoever you are
<Papierkorb> just the guy who started the language
<RX14> lol
<FromGitter> <unreadable> asterite?
<Papierkorb> ya
claudiuinberlin has quit [Quit: Textual IRC Client:]
<FromGitter> <sdogruyol> @RX14 you seem to be angry
<RX14> at what?
<RX14> im not really
<RX14> did you mean what i said "that's one thing ary's good at"?
<RX14> i didn't mean that to come across as rude
<RX14> i just meant i liked that we have a relatively clean issue tracker
<FromGitter> <sdogruyol> that sounded a bit offensive tbh
<FromGitter> <sdogruyol> :P
<FromGitter> <bew> not to me
<RX14> yeah i read it after i wrote it and though
<RX14> maybe i should make a clarification
<Papierkorb> „Don't assume malicious intent“
<FromGitter> <sdogruyol> I just opened the chat, that maybe the cause
<FromGitter> <sdogruyol> no offense here
<crystal-gh> [crystal] RX14 closed pull request #5108: Add Time.monotonic to return monotonic clock (master...std-time-monotonic)
<FromGitter> <iambudi> Hi morning, can someone tell me what is the meaning of this code `self.responds_to?(:[]?)`
<FromGitter> <faustinoaq> > How can I access user_id? I thought faustinoaq is available that's why I mentioned him ⏎ ⏎ @iambudi see: ⏎ ⏎ 1)!topic/crystal-lang/SqAEIF_DiL8 ... []
<crystal-gh> [crystal] werner opened pull request #5170: Fix bug when Hash only has one nil value (master...fix_compact_nil)
<FromGitter> <faustinoaq> > I thought faustinoaq is available that's why I mentioned him ⏎ ⏎ @iambudi I need a break away from computer XD, I'm procrastinating too much ;)
devil_tux has quit [Quit: Lost terminal]
gcds has joined #crystal-lang
<FromGitter> <iambudi> @faustinoaq Actually it’s @ansarizafar who asked and mentioned you. I just replied 😊
<FromGitter> <iambudi> with quote
<FromGitter> <faustinoaq> Thanks you! XD
<FromGitter> <iambudi> Just read the link you share from SO. Great answer @faustinoaq
<FromGitter> <faustinoaq> 👍
<FromGitter> <iambudi> I saw something like JSON::Any
<FromGitter> <iambudi> is it similiar thing?
<FromGitter> <faustinoaq> JSON::Any is just an alias of multiples types
<RX14> no it's not
<RX14> it's a wrapper around an alias
<RX14> JSON::Type is the alias
<FromGitter> <iambudi> That could be implemented as well for nested hash?
<RX14> hmm?
<travis-ci> crystal-lang/crystal#007899a (master - Fix: always use monotonic clock to measure time): The build passed.
<hightower3> Hey folks, silly question, how do I do something like "string".gsub /(\S)/, $1 ?
<RX14> does that not work?
<hightower3> No, the use of $1 throws error
<RX14> oh, no
<RX14> because $1 is evaluated before the function
<oprypin> whaaat
<RX14> you need the $1 in a block so its evaluated for every match
<RX14> oprypin, hmm?
<oprypin> maybe it's just me but i'd write it as `p "string".gsub(/(\S)/, "\\1")`
<RX14> does that work?
<oprypin> i dont know, because this also happens to be the worst regex example ever
<oprypin> but i think so
<RX14> i hope not
<RX14> oh
<RX14> theres a backreferences param
<RX14> and its true by default
<RX14> i wouldn't have put it on bty default opersonally
<RX14> too much magic
<crystal-gh> [crystal] werner closed pull request #5170: Fix bug when Hash only has one nil value (master...fix_compact_nil)
<hightower3> Used the block approach, thanks as always
<FromGitter> <drosehn> Somewhere in either ruby or crystal documentation (or both!) it's noted that "\\1" is supported for replacements in `.sub` and `.gsub`, and that the only reason it's supported is because of the problem with trying to use `$1` as a parameter to those methods.
<FromGitter> <drosehn> I suspect I read it in some crystal documentation somewhere, because it's been a long time since I would have looked that up in ruby documentation.