straight-shoota has quit [Ping timeout: 256 seconds]
jhass has quit [Ping timeout: 260 seconds]
straight-shoota has joined #crystal-lang
jhass has joined #crystal-lang
ur5us has quit [Ping timeout: 246 seconds]
<madprops>
what's the point of the specs using the special language instead of doing something like `assert x == 4` or similar?
<FromGitter>
<oprypin:matrix.org> madprops, "ruby did it so it must be good", or """it looks like English""". no actual point just nobody second-guesses it
<FromGitter>
<lstrzebinczyk> Hi everyone! I'm working on an app and one particular issue about the type system has been bothering me a little bit, I wanted to ask about it. I was going to review issues to see if it's mentioned, but turns out there is 1300 opened issues 😅 . I prepared a code snippet: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ My question is this: Can I mark type of `Builder#inner` to be "The same as
<FromGitter>
... Inner#create" in any way? Typescript has the ability to recover typing of functions with `Parameters`, I was hoping to do something similiar : ). Or also, in typescript I could define `interface`, which I could then use in 2 places. Any advice on what are my options? [https://gitter.im/crystal-lang/crystal?at=63ceff3fcea93403344943b6]
<FromGitter>
<Blacksmoke16> so the gist of it is you want the error to point at the `#inner` method and not the constructor of `Inner` itself yea?
<FromGitter>
<lstrzebinczyk> yes : )
<FromGitter>
<lstrzebinczyk> without defining the types twice
<FromGitter>
<Blacksmoke16> id prob just declare the types twice
<FromGitter>
<Blacksmoke16> tho i may have a way to make that easier
<FromGitter>
<lstrzebinczyk> I see, so currently the language doesn't support pointing to types of other methods?
<FromGitter>
<lstrzebinczyk> or defining interfaces, that could then be used?
<FromGitter>
<Blacksmoke16> interfaces exist, but wouldnt help in this case since its multiple arguments
<FromGitter>
<lstrzebinczyk> what do you refer to?
<FromGitter>
<Blacksmoke16> can leverage some metaprogramming to basically auto define the builder method with the constructor args duplicated
<FromGitter>
<Blacksmoke16> tho it does make some assumptions, like each type only have 1 constructor
<FromGitter>
<lstrzebinczyk> I'm afraid that wouldn't work in my case, though my code snippet might have been a bit misleading. I'm doing quite a bit more logic in these methods, like so: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=63cf028d8e760b51fd049b44]
<FromGitter>
<lstrzebinczyk> this is from the actual code I'm working on
<FromGitter>
<lstrzebinczyk> I am going to save that, and potentially make a use of it
<FromGitter>
<lstrzebinczyk> thank you : )
<FromGitter>
<Blacksmoke16> tho really if depending on how many methods/parameters there are, id prob just hard code it all and not use the macro
<FromGitter>
<lstrzebinczyk> Do you think more native support for this kind of operation could come into the language?
quazimodo has joined #crystal-lang
<FromGitter>
<lstrzebinczyk> something like `def inner(**args : Arguments(Inner[:initialize]))`, syntax for which I've just came up with on the spot
<FromGitter>
<Blacksmoke16> i dont think it ever really came up before
<FromGitter>
<Blacksmoke16> feels a bit niche tho
<FromGitter>
<lstrzebinczyk> let me tell you more about what I'm doing and where it came from
<FromGitter>
<lstrzebinczyk> I am working on a hobby project and doing a small desktop app, based on https://oprypin.github.io/crsfml/
<FromGitter>
<lstrzebinczyk> and CrSFML pretty much only provides rectangles and text, so I'm coming up with a framework to declaratively define the ui
<FromGitter>
<lstrzebinczyk> this particular one is in the middle of being reorganized, so it's a bit chaotic, but that's exactly the issue
<FromGitter>
<lstrzebinczyk> since I'm actively working on these components, it changes that my `UI::Button` or `UI::Horizontal` accepts as params
<FromGitter>
<lstrzebinczyk> and now if I change initializer of `UI::Button`, I have about a dozen of places where the `button(...)` is called, but compiler only shows me the issue in the initializer of `UI::Button`
<FromGitter>
<lstrzebinczyk> so I pretty much need to grep my codebase for where it's used
<FromGitter>
<lstrzebinczyk> I don't want to be a broken record, but I think typescript spoiled me, since it has exactly the solution to this 😅
<FromGitter>
<lstrzebinczyk> btw, I absolutely love Crystal!
<FromGitter>
<lstrzebinczyk> interesting, I wasn't aware of that option!
taupiqueur1 has joined #crystal-lang
<FromGitter>
<lstrzebinczyk> Actually, since I'm already in a good place... I'm actually trying to write blog posts about exactly the app I'm working on at https://lstrzebinczyk.github.io/the_empire_blog/. The posts didn't quite get to the issue I'm describing, but they will get there in 1 or 2 posts