<FromGitter>
<mwlang> I end up with this error: Syntax error in expanded macro: mapping:34: expecting token 'CONST', not 'nil' @binance : nil
<FromGitter>
<mwlang> nevermind, I just stumbled upon YAML serializable. That's just like JSON, so I'll go that route.
duane has joined #crystal-lang
flaviodesousa has quit [Ping timeout: 248 seconds]
flaviodesousa has joined #crystal-lang
<FromGitter>
<watzon> Yeah what you were trying isn't possible
duane has quit [Ping timeout: 258 seconds]
laaron has joined #crystal-lang
<wmoxam>
Any chance that Crystal will support LLVM > 6 anytime soon?
absolutejam2 has joined #crystal-lang
absolutejam2 has quit [Ping timeout: 248 seconds]
absolutejam2 has joined #crystal-lang
absolutejam2 has quit [Ping timeout: 258 seconds]
mistergibson has quit [Quit: Leaving]
absolutejam2 has joined #crystal-lang
<FromGitter>
<naqvis> Thanks Julien @j8r. tarball is just a reader of archive with limited support. What I put together is complete reader/writer supporting major format.
<absolutejam2>
how do I define a logger singleton since globals have been removed?
<FromGitter>
<watzon> @absolutejam2 on your main module you can do `class_getter logger = Logger.new` and then you can access it from anywhere by doing `MyModule.logger`
<FromGitter>
<watzon> If I understood your question correctly
<absolutejam2>
ty
<FromGitter>
<watzon> Np
absolutejam2 has quit [Ping timeout: 244 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
<FromGitter>
<vladfaust> @bararchy whatβs the usecase? I hardly can imagine where I do need string enums π€
DTZUZO has quit [Ping timeout: 245 seconds]
<FromGitter>
<girng> string enums??
<FromGitter>
<girng> doesn't that make the performance of enums slower
<FromGitter>
<girng> and completely nullify the entire reason of using enums in the first place?
<FromGitter>
<girng> or, is it just a syntax sugar change, but works fast still under the hood?
<FromGitter>
<vladfaust> I guess. One could simply do `case myenum; when foo? "foo"` etc
<FromGitter>
<bararchy> @vladfaust it looks nicer, and allows me to also MAKE the user choose one of the avilable options without raiseing if he used something unsupported
<FromGitter>
<vladfaust> Confusing to see it w/o `.to_s`. From C-family languages perspective (and also Crystal, as I've got used to it), `selector` is clearly a numeric value, because it's enum
absolutejam has joined #crystal-lang
<FromGitter>
<bararchy> that's a differernt problem all together XD
<FromGitter>
<bararchy> but in my eyes, it's the 3rd time I wished we had a String enum
<FromGitter>
<bararchy> or more prefferebly, a Object Object enum
<FromGitter>
<vladfaust> No language firs every use-case. IMO, knowing that enum is always a numeric value gives more advantage than generic Object enums
<FromGitter>
<yxhuvud> @bararchy is that really a problem best solved by an enum? You could create a class for each variant, and implement a common method on it, so that instead of just doing `value: selector` you would do `value: selector.foo`.
<FromGitter>
<yxhuvud> or not even that if you made the class support json serialization. to_json calls itself on each value in a hash, right?
<FromGitter>
<watzon> The enum way sounds like much less and f a hassle. More efficient too.
sorcus has joined #crystal-lang
<FromGitter>
<Prutheus> I have a string `"1-16 von mehr als 1.000 Ergebnissen oder VorschlΓ€gen fΓΌr erkmann - wohnen design geschenke"` where i wanna get all numbers via regex (regex: `([0-9.]*[0-9]+)`) ... works, check here: https://regex101.com/r/rRmGWy/1
<FromGitter>
<Prutheus> no-one here at the moment?
<FromGitter>
<mavu> @Prutheus I think that is expected behaviour. regexps match once, and return that match. β In ruby for example, you get the exaxt same behaviour, and if you wanted all matches, your would use the .scan() method.
<FromGitter>
<bew> I second @mavu, your regex101 link works because there is a `g` (for `global`) regex option, that make it search all the matches, not just the first one.
<FromGitter>
<Prutheus> what is the crystal function for scan?
<FromGitter>
<bestwebua> Idea for new ```.compact``` feature, opportunity use it with block, like ```arr.compact(&.empty?)```
<FromGitter>
<alexherbo2> Trying to play with sockets
<FromGitter>
<alexherbo2> Itβs created by running `chromium --remote-debugging-port=9222`
<FromGitter>
<Blacksmoke16> @alexherbo2 my understanding is you just https://crystal-lang.org/api/master/HTTP/WebSocket.html#new%28host%3AString%2Cpath%3AString%2Cport%3Dnil%2Ctls%3Dfalse%2Cheaders%3DHTTP%3A%3AHeaders.new%29-class-method
<FromGitter>
<Blacksmoke16> new up a WS, then can invoke the `#send` method to send data to that WS
<FromGitter>
<alexherbo2> there is no need to on_open or something?
<FromGitter>
<mwlang> it's not an entirely correct implementation, but the websocket parts do work.
mistergibson has joined #crystal-lang
<FromGitter>
<mwlang> what's the difference between delegate and forward_missing_to?
<FromGitter>
<mwlang> I guess with forward_missing_to every missing method signature is delegated? whereas delegate, you single out specific methods to delegate?
<FromGitter>
<Blacksmoke16> yes
<FromGitter>
<mwlang> π
absolutejam2 has quit [Ping timeout: 268 seconds]
<FromGitter>
<mobilpadde_gitlab> Hi! How would I go if I have a fiber, unless that fiber has finished I want to put some text every x second. Once finished it'd put something else? Thanks!
<FromGitter>
<mwlang> Send message in channel to main loop and print out that message.
<FromGitter>
<mobilpadde_gitlab> So, like send a message to a channel once it's supposed to finish, and in the main I'd put a `until` to check if finished?
<FromGitter>
<mwlang> oh, you're wanting opposite way around than what I was thinking, but yes, when fiber finishes, it should send a signal on the channel that it completed it's work.
<FromGitter>
<mwlang> the main loop then just checks every second until that message is received.
<FromGitter>
<Blacksmoke16> no, it'll block until there is data in the ch
<FromGitter>
<Blacksmoke16> i mean, if you just want to wait for something to finish that would do it
<FromGitter>
<Blacksmoke16> i.e. program would hit that, wait for fiber the send a value, then hit that if statement
<FromGitter>
<yxhuvud> I think it is possible to do by selecting over multiple channels, where one channel is a fiber that simply fires an event every once in a while
<FromGitter>
<mobilpadde_gitlab> Wait, now my first fiber won't fire?
<FromGitter>
<Blacksmoke16> is the end goal here to just have a bunch of fibers run and wait until they all done?
<FromGitter>
<mobilpadde_gitlab> One fiber doing some heavy lifting, and something else sleeping for like a sec, put some content, then stopping when the fiber is done
<FromGitter>
<Blacksmoke16> but prob not since you would need to communicate when the heavy fiber is done to the puts fiber
<FromGitter>
<mwlang> ugh! still struggling with the pattern of passing on the object I'm initializing to the child objects I want to create while in the initialize constructor.
<FromGitter>
<mwlang> almost like I'm going to have to start doing Factory patterns to build in two steps if I want to continue thinking this way.
<FromGitter>
<mwlang> yeah, that's what I'm gonna do. I don't remember Delphi having this issue with it's constructor.
<FromGitter>
<mwlang> So I wonder why Crystal can't have proper access to "self" inside #initialize calls
<FromGitter>
<mwlang> sure it may not be fully initialized yet, but surely the pointer to "self" can be obtained and set in child classes and it'll all tie together later when accessed.
<FromGitter>
<Blacksmoke16> id need to see an example if you want to make a playground
<FromGitter>
<girng> but.. then again, i'm the kind of the person who would do... `p = Test.new`, then `p.name = "Korale"` LOL
<FromGitter>
<Blacksmoke16> easiest way is to just do like `def initialize(@name : String); end` then `p = Test.new "Name"`
<FromGitter>
<girng> ye true
<FromGitter>
<mwlang> @naqvis I didn't know about `Hooks` Reading up now...
<FromGitter>
<mwlang> I think I have it working now. https://play.crystal-lang.org/#/r/76p8 is the "contrived example" and I got it working in the playground.
<FromGitter>
<mwlang> turns out, the key was to set the getter directly in the initialization. Then I could call another method after that to populate the getter's array with objects.
<FromGitter>
<mwlang> my use case is that I'm initializing my connection to Binance exchange as a BinancePortal object and immediately assigning all the markets (ticker symbols) at the outset. So it's the BinancePortal instance that self-populates it's array of markets.
<FromGitter>
<girng> :D
<FromGitter>
<mwlang> @girng reading that ticket, I'd say they're talking about using crystal to write dynamically linked libraries.
<FromGitter>
<mwlang> basically external libraries that provide useful collection of functionality to other apps to link/bind to.
<FromGitter>
<girng> ohhh dynamically linked libarires like DLLs
<FromGitter>
<mwlang> like writing libxml or imagemagick in Crystal instead of C.
<FromGitter>
<mwlang> yes.
<FromGitter>
<girng> i was thinking of a shard or somethign that "dynamically updates" based on crystal version or something lol
<FromGitter>
<girng> i was like don't we already have shards
<FromGitter>
<mwlang> I can see that.
<FromGitter>
<girng> everyone else got it though, sometimes i derp
<FromGitter>
<girng> heheheh
<FromGitter>
<girng> hey @mwlang just curious
<FromGitter>
<girng> Where did you hear about Crystal?
<FromGitter>
<mwlang> I'm sure from my Ruby sphere. I've known about Crystal for about 5, maybe 6 years now and periodically tried it out here and there over the years.
<FromGitter>
<mwlang> but it was only recently that I had a use case powerful enough to warrant adopting and using Crystal.
<FromGitter>
<girng> wow really
<FromGitter>
<mwlang> I've been a Ruby developer since 2006
<FromGitter>
<mwlang> and can build pretty much anything I need using Ruby...but recently, I'm handling so much data that is time-sensitive that I needed a compilable language like crystal to get the speed.
<FromGitter>
<girng> That's awesome, I came from nodejs lol
<FromGitter>
<mwlang> I use nodejs as well.
<FromGitter>
<girng> I actually never even used Ruby before, but boy do I like the syntax!!
<FromGitter>
<mwlang> or really, webpack embedded into Ruby on Rails projects.
<FromGitter>
<mwlang> me too. once you master it, you can really pack a punch in only a few lines of code and it remains highly readable.
<FromGitter>
<girng> so true
<FromGitter>
<girng> in js i really like objects, i like how in crystal we can create a Class, then do property xxx and access it by dot notation, like an object
<FromGitter>
<mwlang> I'm loving the fact that I can "think in Ruby" and more or less get to where I was headed with crystal.
<FromGitter>
<girng> feels good, i like oop
<FromGitter>
<mwlang> that's exactly what I was doing with the binance shard....turning all that JSON into class objects.
<FromGitter>
<girng> have you noticed any performance improvements already
<FromGitter>
<mwlang> HUGE
<FromGitter>
<girng> lol awesome
<FromGitter>
<girng> if you got time, it sounds interesting what youa re doing. i'd love to read a blog post about it
<FromGitter>
<girng> comparison from ruby speed to crystal
<FromGitter>
<mwlang> I was computing bollinger bands from thousands of candles (stock market charts)
<FromGitter>
<mwlang> 19 minutes in Ruby vs. 3 seconds in Crystal
<FromGitter>
<girng> Dang
<FromGitter>
<mwlang> A lot of it was shared in this gitter...you just have to scroll up long enough to find it. :-)
<FromGitter>
<girng> yea those numbers and floats in strings from api lol
<FromGitter>
<mwlang> keep on going back and you'll find some performance metrics from when I first started.
<FromGitter>
<Blacksmoke16> > in js i really like objects, i like how in crystal we can create a Class, then do property xxx and access it by dot notation, like an object β β Yet you dont really use them in crystal :P
<FromGitter>
<girng> :D
<FromGitter>
<girng> I use em for my Player class lol
<FromGitter>
<girng> but yeah, i should be doing more OOP
<FromGitter>
<girng> especially in game dev i think it helps a lot
<FromGitter>
<mwlang> actually, search for "bollinger" That'll get you close to the conversation.
<FromGitter>
<mwlang> OOP is especially suited to game development.
<FromGitter>
<girng> yeah it works well doesn't it
<FromGitter>
<girng> i mean, i use OOP. but i pass stuff to functions a lot since classes are pased by reference in crystal
<FromGitter>
<mwlang> well, you're building an interactive world of "objects" might as well apply OOP to the modeling of your domain. :-)
<FromGitter>
<girng> i just find it easier for a function to do something
<FromGitter>
<mwlang> A lot of people do.
<FromGitter>
<girng> on a class, instead of that class modifying itself
<FromGitter>
<girng> (if that makes sense)
<FromGitter>
<mwlang> well, service pattern sounds like what you just described for the former.
<FromGitter>
<Blacksmoke16> vs just doing `c.do_something`, which modifies itself
<FromGitter>
<girng> i don't even use `c : MyClass`
<FromGitter>
<Blacksmoke16> π
<FromGitter>
<girng> i just pass it in lmaoo
<FromGitter>
<Blacksmoke16> not getting any type safety then
<FromGitter>
<girng> if crystal compiler don't complain, i'm game
<FromGitter>
<Blacksmoke16> *sigh*
<FromGitter>
<girng> all my type safety's are done in property xxx : Type
<FromGitter>
<girng> i don't use type safety for arguments
<FromGitter>
<Blacksmoke16> prob should
<FromGitter>
<Blacksmoke16> for how easy it is to add
<FromGitter>
<girng> well, if crystal complained about it i prob would have. i just did trial an error and if it works and no compiler errors, i just continue to code lol
<FromGitter>
<girng> but i mean i should...
<FromGitter>
<Blacksmoke16> and you should write tests π
<FromGitter>
<Blacksmoke16> define the same method multiple times with diff restrictions, and complier knows how to route each method call based on the type
<FromGitter>
<girng> ROFL
<FromGitter>
<girng> i would never use 2x some_method's though
<FromGitter>
<girng> that doesn't look right
<FromGitter>
<girng> 2 of the same method names... WTF
<FromGitter>
<Blacksmoke16> that take diff types
<FromGitter>
<mwlang> hey, that's the good stuff. :-)
<FromGitter>
<girng> nah, i differentiate methods by name, not types
<FromGitter>
<Blacksmoke16> but then you would need to do like
<FromGitter>
<girng> if you do it with types = more confusing
<FromGitter>
<Blacksmoke16> not really
<FromGitter>
<girng> cause by this logic, you could have tons of some_method's
<FromGitter>
<girng> and the developer now has to look at the arguments and class first, instead of just the method name
<FromGitter>
<Blacksmoke16> thats whats going on in a good amount of methods
<FromGitter>
<Blacksmoke16> `sub` method for example is defined with various restrictions that allow it to work given, in this case, a char, string, and regex
<FromGitter>
<Blacksmoke16> SO you could then use a common method that knows what to do no matter that type given to it
<FromGitter>
<girng> but the method is created specifically to interact with that class
<FromGitter>
<girng> so that would never happen
<FromGitter>
<Blacksmoke16> name is common enough where it could
<FromGitter>
<Blacksmoke16> the point of all this is reducing the changes that a bug could happen
<FromGitter>
<Blacksmoke16> which you can solve via `c : MyClass`
<FromGitter>
<Blacksmoke16> now you know that will never happen
<FromGitter>
<girng> i like that
<FromGitter>
<girng> but that's about as far asi'll go
<FromGitter>
<girng> in terms of type safety
<FromGitter>
<girng> i feel like crystal's compiler will detect most of this crap in advance, if you can get it compiled you should be fine
<FromGitter>
<Blacksmoke16> that compiled but would have a bug at runtime
<FromGitter>
<Blacksmoke16> it can only catch so much
<FromGitter>
<girng> depends if the dev writes bad code
<FromGitter>
<mwlang> typing the method parameters can allow you to intentionally restrict what's coming in. Sometimes you want it open (as you do here) and sometimes you *don't* -- it's a design/implementation decision and at least with Crystal, you can enforce (or choose not to)
<FromGitter>
<Blacksmoke16> tests would have picked that up
<FromGitter>
<naqvis> I can see that @girng still used to JS writing of functions. Your code might be clear to you, but it would be difficult for other developers to read and understand? As looking at the method signature, there is no way in knowing what type of object or argument your method is expecting
<FromGitter>
<mwlang> with Ruby, you can't. You'll have to add guards in the method's implementation to enforce incoming type restrictions.
<FromGitter>
<naqvis> and iβm sure you will have to go through whole code base again if you revisit your code after some break :)
<FromGitter>
<girng> well, imo, having multiple method names of the same exact name scattered throughout code is far more confusing than simply not using `c : MyClass` on an argument for 1 unique method, that modifies 1 certain type of class..
<FromGitter>
<mwlang> one thing I'm happy about with Crystal. There's a whole swath of unit tests I no longer have to write.
<FromGitter>
<girng> different strokes for different folks, I guess
<FromGitter>
<Blacksmoke16> if mean if each of those methods is doing a similar thing, it would be more clear to have them named what they do, vs what that do it to
<FromGitter>
<mwlang> well, it's not impossible to code your way and it's obviously working for you, so no harm in that. But I can definitely say you're coding harder than you have to overall because you close off a good deal of power of the language to your use.
<FromGitter>
<Blacksmoke16> then you can easily figure out which one it is, based on the type you're passing (as they would all be restricted)
<FromGitter>
<Blacksmoke16> ^^
<FromGitter>
<naqvis> yup, also your approach break the very basic tenant of OOP, that is encapsulation as you are mutating object outside the class where it is defined :)
<FromGitter>
<girng> if crystal starts complaining about not having c : MyClass in the argument, i'll fix it. otherwise, I think crystal knows it's going to be that type, and that method is ONLY EVER going to be used with that class, there is literally no chance of a bug ever happening. That method is tied to that object. Only way a bug would happen is if I pass in the wrong object, but crystal would already detect that, and I would
<FromGitter>
... never do that, because that method is for that specific class anyway. Littering your code with duplicate method names and redundant type safety checks that are not even needed, is not good code.
<FromGitter>
<naqvis> I agree, every one has his/her own preferred approach of writing code. Coding is just a fun, so letβs do it in a way, which makes one happy
<FromGitter>
<Blacksmoke16> > Only way a bug would happen is if I pass in the wrong object, but crystal would already detect that, β β It wouldnt if it happened to have the same methods
<FromGitter>
<Blacksmoke16> the type restriction would solve, (or better yet have the method within the class versus being a separate def out in top level)
<FromGitter>
<girng> i think that's cool and makes sense in terms of creating an API
<FromGitter>
<girng> but for a specific hobby project, redundant method names that are the same is silly
<FromGitter>
<Blacksmoke16> got an ETA when its going to be released?
<FromGitter>
<mwlang> well, for me, I knew my method to get an optional parameter added to the params object was called `#optional_param` and that's all I needed to remember vs. optional_param_from_s, optional_param_from_int32, etc.
<FromGitter>
<girng> i mean look at all the type inferences crystal does
<FromGitter>
<girng> crystal wants you to write basic code
<FromGitter>
<Blacksmoke16> you could write terrible code and it would happily compile
<FromGitter>
<girng> that is readable, less convoluted, and makes sense
<FromGitter>
<Blacksmoke16> just because it complies doesnt mean its *good* code
<FromGitter>
<girng> i agree, dev still has to write good code, but it's pretty hard to write bad code with crystal
<FromGitter>
<mwlang> nobody saying they don't love that aspect of Crystal. ;-) I love it myself and leverage here and there...when I *think* there's a risk of misuse, I'll add the type declarations to the method call signature to keep things sane.
<FromGitter>
<girng> if you can get crystal to compile, chances are, you have decent code
<FromGitter>
<Blacksmoke16> not true :P
<FromGitter>
<Blacksmoke16> i can only imagine the nightmare that would be making a PR to @girng's game
<FromGitter>
<girng> the only time i wrote bad code in crystal is when i assigned a const array to a new property, it was referenced to all the players
<FromGitter>
<Blacksmoke16> have a feeling you're the only one that can dev on it
<FromGitter>
<girng> crystal never told me that
<FromGitter>
<girng> that is the only bug i had that would have screwed me over
<FromGitter>
<girng> that is a developer writing bad code
<FromGitter>
<girng> (me)
<FromGitter>
<girng> developer would think since you are creating a new array foreach time that class is initialized, it's getting a new array for that property. doesn't happen if that instance variable references a const array
<FromGitter>
<girng> crystal should actually tell the developer this imo
<FromGitter>
<Blacksmoke16> how would it know
<FromGitter>
<Blacksmoke16> arrays are passed by reference
<FromGitter>
<girng> good question iuno
<FromGitter>
<Blacksmoke16> we'll convince you one of these days
<FromGitter>
<mwlang> I'm actually surprised by this example...a CONST defined was allowed to change through dynamic assignments.
<FromGitter>
<mwlang> Ruby would bark at this.
<FromGitter>
<girng> @Blacksmoke16 ^^^^
<FromGitter>
<Blacksmoke16> it didnt change, it was mutated
<FromGitter>
<mwlang> heh, ok, mutated. It should be immutable.
<FromGitter>
<naqvis> @mwlang , const is only for ref, not for the object it is pointing to
<FromGitter>
<Blacksmoke16> yea, only means it cant be reassigned
absolutejam3 has joined #crystal-lang
<FromGitter>
<naqvis> thatβs normal behavior in all languages including Java, C#, Go
<FromGitter>
<girng> @naqvis yeah i used an array literal / dup for the fix
<FromGitter>
<girng> fix in the sense of me writing bad code, not issue with language
<FromGitter>
<mwlang> not sure if we're talking about the same thing, but I just mean that CHAR_IMG, once initially assigned [0,0,0,0] should cause a compiler error if it's somehow changed at later point to [1,0,0,0]
absolutejam2 has quit [Ping timeout: 246 seconds]
<FromGitter>
<Blacksmoke16> eh, depends on how you look at it...
<FromGitter>
<girng> when a player equips a wep/armor/boot/glove/shield, this array gets updated. so just saying, this would have been the worst bug ever to catch, everyone would complain their characters are being updated with the wrong items equipped. as the last player on that instance server who equipped an item, that char_img would be changed for everyone looooool
<FromGitter>
<naqvis> CHAR_IMG is a constant which is pointing to reference to an Array. Array itself is an object. You canβt re-assign CHAR_IMG, but you can definitely mutate the object
<FromGitter>
<Blacksmoke16> yea, but one could argue they would expect it to not be able to be changed at all since its a constant
<FromGitter>
<mwlang> I guess, crystal doesn't have concept of FOO = [0,0,0,0].freeze
<absolutejam3>
whenever I see `def initialize(@foo)` I think there should be a nice notation to end the method on the same line
<absolutejam3>
if that's all that is needed
<FromGitter>
<Blacksmoke16> or in typescript land like `readonly const foo = [0,0,0,0];`
<FromGitter>
<Blacksmoke16> er i think that allows it to be mutated as well
<FromGitter>
<girng> what's diff between a mutable const and a regular const?
<absolutejam3>
like Elixir has `def foo(a), do: a` for single line declaration (although, different intent from what I'm saying)
<FromGitter>
<girng> i thought constants are immutable
<absolutejam3>
Haven't tried `def initialize(@foo); end` to be honest, but looks a bit clumsy
<FromGitter>
<girng> or, does it depend on the language the developer is using
<FromGitter>
<Blacksmoke16> would have to do like `const foo: ReadonlyArray<number> = [0,0,0,0];`
<FromGitter>
<mwlang> crap...without "freeze" even Ruby lets you change constants' values
<FromGitter>
<Blacksmoke16> time for a `readonly` keyword? :P
<FromGitter>
<mwlang> but I've gotten pretty habitual in defining constants with #freeze, so actually kind of forgotten this!
<FromGitter>
<naqvis> its normal semantic as `const` only affect the assignment operator and the object isnβt really constant, unless its an object of some immutable class
<FromGitter>
<mwlang> or just tacking on `.freeze`
<FromGitter>
<girng> So, when a struct is "passed by value", it's not 100% passed by value, it depends on its properties and if they are referenced or not, correct
<FromGitter>
<naqvis> correct
<FromGitter>
<Blacksmoke16> `property` defines both a getter and setter for the ivar
<FromGitter>
<Blacksmoke16> dont need the top return
<FromGitter>
<Blacksmoke16> is the same as the one below it
<FromGitter>
<Blacksmoke16> mhm
<FromGitter>
<Blacksmoke16> guard clauses ftw
<FromGitter>
<girng> what the hell
<FromGitter>
<girng> inever knew that
<FromGitter>
<girng> i thought the local variables had to be used inside their if else blocks
snsei__ has quit [Remote host closed the connection]
<FromGitter>
<girng> if end*
<FromGitter>
<girng> but it actually works
snsei__ has joined #crystal-lang
<FromGitter>
<girng> this is gonna save a lot of lines, and increase readability tenfold
<FromGitter>
<girng> @Blacksmoke16 ty
<FromGitter>
<Blacksmoke16> np
<FromGitter>
<girng> i hated the the nested ifs were getting anoying af lol
<FromGitter>
<Blacksmoke16> `raise "Runes, Skills, or Misc items cannot be modified." if {"Skills", "Misc", "Runes", "Flasks"}.includes? main_on_item["type"]` would require big changes id imagine but this types of stuff is the perfect example of OOP + inheritance
<FromGitter>
<Blacksmoke16> want an example?
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
<FromGitter>
<Blacksmoke16> i dont know enough to suggest the model of what everything would look like but the idea is
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
<FromGitter>
<girng> iuno depends, everything wroks nicely i don't really want to change anything atm just gonna do these guard clauses tho
snsei__ has joined #crystal-lang
<FromGitter>
<girng> cause that enhances readability a lot for me
<FromGitter>
<Blacksmoke16> ofc, it would be a big rewrite
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>
<Blacksmoke16> im telling you, once you start you'll like it
<FromGitter>
<Blacksmoke16> but its a lot harder when you have monster methods like this if not impossible
<FromGitter>
<Blacksmoke16> so prob not even easily doable anymore
laaron has quit [Remote host closed the connection]
<FromGitter>
<girng> i'll try to write some later
<FromGitter>
<girng> for like 1 method and just see how it goes
<FromGitter>
<girng> one of the nasty methods
<FromGitter>
<Blacksmoke16> β€οΈ we're making progress
laaron has joined #crystal-lang
<FromGitter>
<girng> i'm just thinking of so many ideas and coding, i'm on a roll. that's why i like about crystal, i can get my thoughts into code fast. but then again, that's why tests are probably there. to be there for the developer to catch stuff, a helping hand
<FromGitter>
<Blacksmoke16> yes, so that you dont have to manually test as much when you make changes
teardown has joined #crystal-lang
<FromGitter>
<Blacksmoke16> have a feeling its going to be hard to write tests just based on the design of how you structured the game
<FromGitter>
<tenebrousedge> or to prove correctness. And tests are also documentation
<FromGitter>
<mwlang> @watzon Dude. Are you mind-melding me? I just stumbled upon https://svelte.dev/blog/write-less-code and was reading that a few minutes ago. Some really, *really* good ideas going on in this framework that's singing to me and my sense of less code, less bloat, higher performance, and, best of all, gigantic reduction of bandwidth to my end users.
<FromGitter>
<Blacksmoke16> what about it @tenebrousedge ?
<FromGitter>
<tenebrousedge> @Blacksmoke16 just want a sanity check on the general approach
<FromGitter>
<mwlang> I'm going to see about injecting svelte into my new crystal project now and use that instead of vue.js
rohitpaulk has quit [Remote host closed the connection]
<FromGitter>
<Blacksmoke16> not really sure whats going on
<FromGitter>
<tenebrousedge> @Blacksmoke16 scanf is a kind of DSL for extracting information from strings, basically the inverse of printf
<FromGitter>
<tenebrousedge> hmm, I'll bookmark that
<FromGitter>
<Blacksmoke16> is basically what athena does with route/query params
<FromGitter>
<Blacksmoke16> for primitive types, complex ones require a converter to specify the logic of what should happen
<FromGitter>
<tenebrousedge> `scanf` only handles strings, numbers, and pointers
<FromGitter>
<Blacksmoke16> well there you go, is all you need then
<FromGitter>
<Blacksmoke16> how would a pointer work?
<FromGitter>
<tenebrousedge> I dunno. It seems like a bad idea
<FromGitter>
<tenebrousedge> but Crystal should support anything that C/C++ supports
<FromGitter>
<watzon> Not necessarily
<FromGitter>
<tenebrousedge> o.o?
<FromGitter>
<asterite> I tried to implement scanf once, I can't remember how I did it
<FromGitter>
<asterite> but it has to be safe...
<FromGitter>
<asterite> the problem with scanf is that it receives references to variables which have to have a type, so it's kind of opposite to how you program in crystal, where the types are inferred
<FromGitter>
<asterite> I guess one way would be to do something like `"an int between single quotes: '%'".scanf(Int32)`
<FromGitter>
<asterite> then each `%` is matched against the given type, and each type would have to implement a way to consume input
<FromGitter>
<asterite> then scanf becomes extensible, you could parse `"point: %".scanf(Point)` and `Point` could parse stuff like "x, y"
<FromGitter>
<asterite> but scanf in Ruby is not used a lot for some reason... I think regex has a simpler interface, even though it's slower
<FromGitter>
<watzon> I feel like thats the main reason, speed
<FromGitter>
<watzon> With ruby you need any performance increase yo ucan get
<FromGitter>
<asterite> Yes, but scanf in Ruby is actually slower than using a regex
<FromGitter>
<asterite> The thing is that a regex might be compiled, while with scanf the pattern has to be parsed over and over... though I'm not sure that's the reason it's slower
<FromGitter>
<asterite> then regex is way more flexible, you can specify exactly how to parse a word, or a number
snsei__ has quit [Ping timeout: 276 seconds]
<FromGitter>
<girng> interesting
<FromGitter>
<Blacksmoke16> @mwlang angular isnt far off from that num of chars
<FromGitter>
<Fryguy> I can't understand *why* though
<FromGitter>
<Blacksmoke16> `Topic has not received significant coverage in reliable sources that are independent of the subject, so it fails GNG Charmk (talk) 19:10, 5 July 2019 (UTC)`
<FromGitter>
<Fryguy> yeah, I'm also seeing Nim with the same rationaly
<FromGitter>
<mwlang> ok, found the /sbin/my_init and changed that.
<FromGitter>
<Blacksmoke16> granted your dockerfile is much more complex than mine...
<FromGitter>
<mwlang> I'll take a simpler one if you want to share it.
<FromGitter>
<Blacksmoke16> but not sure there is a way around it since you have to install more stuff
<FromGitter>
<mwlang> ok, I'm getting somewhere.
<FromGitter>
<mwlang> Cannot start service web: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"lucky\": executable file not found in $PATH": unknown
<FromGitter>
<mwlang> so now...get shards installed or get the right path to lucky configured...
<FromGitter>
<Blacksmoke16> should just have to change your command to maybe like `./bin/lucky watch`
<FromGitter>
<Blacksmoke16> assuming your work dir is the root
<FromGitter>
<mwlang> actually, I don't think it's installing crystal...working on that now.
<FromGitter>
<Blacksmoke16> should already be installed if you use the crystal docker image
<FromGitter>
<mwlang> stealing docker files from amber project.
<FromGitter>
<mwlang> I wasn't using crystallang image just then...now am.
<FromGitter>
<Blacksmoke16> that would do it
<FromGitter>
<mwlang> gone through a bunch of iterations.
<FromGitter>
<mwlang> just trying stuff...but now trying to do it a bit more constructively.
absolutejam4 has quit [Ping timeout: 268 seconds]
<FromGitter>
<mwlang> how do I just not run a command and bring up image so I can launch a bash shell?
<FromGitter>
<mwlang> I need to go hunt for where `lucky` gets installed when shards install runs.
<FromGitter>
<Blacksmoke16> if the container is already running you can do like