jhass changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.1 | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
alexherbo2 has quit [Ping timeout: 246 seconds]
DTZUZU_ has joined #crystal-lang
DTZUZU has quit [Ping timeout: 246 seconds]
_whitelogger has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
f1refly has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 272 seconds]
zorp has joined #crystal-lang
<FromGitter> <Nicolab> Converting JSON translation files to YAML => oq => thanks for this tools @Blacksmoke16 👍
<FromGitter> <Blacksmoke16> 💯 good to hear :)
<FromGitter> <Nicolab> with pleasure, thanks
gangstacat has quit [Ping timeout: 272 seconds]
gangstacat has joined #crystal-lang
<FromGitter> <mattrberry> @oprypin Now that I'm working on a gba emulator, I'm starting to realize how much it'd be nice to have actually good sdl2 bindings rather than a hacky mix of ysbaddaden's bindings and my own. If you ever end up doing that, please let me know 👉👈
<oprypin> @mattrberry: haha oh i probably won't 😩. my thing has been to bind libraries which already have an object-oriented API so I don't need to think too much
<oprypin> so c++ libs and libchipmunk which somehow pulls off being OO in pure C
<oprypin> @mattrberry: i forget, what made you decide against sfml
<yxhuvud> IMO OO C == Good C. Fight me.
<yxhuvud> depending on what you mean by OO C of course. If you mean the old variants using *** pointers, then I feel your pain.
<FromGitter> <mattrberry> @oprypin I initially used your sfml bindings, but when I tried them I had a lot of trouble getting them to work because of versioning issues. When I did get that to work, then I felt like sfml’s audio interface was more confusing than sdl’s. I’ve considered revisiting it since I didn’t know *anything* about audio at the time, but I’ve been happy enough with sdl to not bother
<oprypin> versioning issues 🤔
<oprypin> that one might have gotten a little better (it doesn't put its own additional .so file now)
<FromGitter> <mattrberry> Iirc I had issues just getting sfml installed in the first place and I had to build from source just to get a reasonably recent build. Then I had issues with crsfml not liking my instal for some reason
<oprypin> audio - yea i don't know much about it. definitely know 0 about audio in sdl, can't comment
<FromGitter> <mattrberry> I’d have to look at it again since the last time I tried crsfml was back at the end of April
<oprypin> april was an interesting time https://github.com/oprypin/crsfml/releases/tag/v2.5.1
<oprypin> if you tried th this release already then not much changed
<oprypin> w
<FromGitter> <mattrberry> Looks like my first use was 2.5.1 on April 30th https://github.com/mattrberry/chip-8/commit/595e1102572775b12e74208ab31dbf67160b15ca
<oprypin> 😩
<FromGitter> <mattrberry> It might be worth a shot again because you’ve already integrated it with your imgui bindings, but I’d just be weary about the audio interface. I’d want to give it a try first. Tbh it shouldn’t be too challenging to drop in as a replacement for sdl if it works though. At least for graphics
<oprypin> dang, well then there's no big breakthrough in crsfml, all i can say is, I'd be glad to help :D
<oprypin> ah let Hacktoberfest begin! https://github.com/crystal-lang/crystal/pull/9786
<FromGitter> <mattrberry> I’ll let you know, maybe I’ll take a look again this weekend!
<FromGitter> <grkek> Hello, I updated the Grip framework and created a cute little documentation page
<FromGitter> <grkek> more info is there :)
<FromGitter> <j8r> Good! How the doc is generated? I see can't see on the CI files
<FromGitter> <j8r> ha ok, I thought at first API docs
<FromGitter> <j8r> That's quite strange not to generate API docs at first, which is the simplest to do
deavmi has quit [Ping timeout: 246 seconds]
deavmi has joined #crystal-lang
<FromGitter> <grkek> Not a fan of the style the crystal uses for the docs tbh
<jhass> I wish https://devdocs.io/ would keep the Crystal docs up-to-date
gangstacat has quit [Ping timeout: 240 seconds]
<FromGitter> <asterite> @mattrberry yeah, I really wish there were really good, complete bindings for SDL2. I think we would need someone with: knowledge of SDL2, knowledge of Crystal and time/willingness to do it. But it would make doing things on top of SDL2 much easier.
<FromGitter> <Blacksmoke16> i personally like the API doc approach, makes it harder for them to get out of date, and keeps the docs close to the code its describing
pciuch9 has joined #crystal-lang
pciuch9 has quit [Ping timeout: 260 seconds]
riffraff169 has joined #crystal-lang
<FromGitter> <mattrberry> @asterite It’s somewhere on my todo list, but a pretty long way off tbh. Outside of work, I’ve only been finding about an hour or two per day to work on projects :/ I have a handful of projects queued up before that point. Hopefully somebody else with more time comes around in the meantime
sorcus has quit [Ping timeout: 246 seconds]
issyl0 has joined #crystal-lang
issyl0 has quit [Ping timeout: 244 seconds]
jetpack_joe has quit [Ping timeout: 244 seconds]
jetpack_joe has joined #crystal-lang
melthelesbian has joined #crystal-lang
jetpack_joe has joined #crystal-lang
melthelesbian has quit [Ping timeout: 244 seconds]
jetpack_joe has quit [Ping timeout: 244 seconds]
r0bby has joined #crystal-lang
r0bby has quit [Ping timeout: 244 seconds]
gangstacat has joined #crystal-lang
<oprypin> @Blacksmoke16: of course it's a good approach. just shit implementation
<FromGitter> <Blacksmoke16> not going to get super fancy docs, but it does its job
Reiser has joined #crystal-lang
<Reiser> Hey guys, is it possible to create a scoped block in Crystal? I.E, I just want to create a scope temporarily so I can throw away some variables, similar to: `{ auto x = 1; auto y = 2; }` in C++ let's say
<FromGitter> <Blacksmoke16> would that not just be a local variable?
<Reiser> I'm writing at the main file scope though
<Reiser> But yeah that's what I'm after, I want to introduce a scope so that I can create local variables temporarily
<Reiser> Something like this but valid Crystal
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 256 seconds]
<oprypin> Reiser: Crystal doesn't have scopes basically
<Reiser> Ah, I guess I'll just define methods for everything, no worries
<oprypin> a function creates a scope but they can't be nested
<oprypin> the only time that there can be an outer scope is the enclosing class
<yxhuvud> And when you create a proc, no?
<yxhuvud> or do they only have a pointer to the instance that created it?
<oprypin> interesting point
<oprypin> wow you're actually right
zorp has quit [Ping timeout: 260 seconds]
<oprypin> ->{ xxx }.call is the way to create a scope
<Reiser> I did try that actually
<Reiser> But couldn't figure out how to write multiline bodies
<FromGitter> <Blacksmoke16> ```Proc(Nil). do ⏎ # ... ⏎ end.call``` [https://gitter.im/crystal-lang/crystal?at=5f776385a5ac94398069b1f2]
<FromGitter> <Blacksmoke16> ?
<FromGitter> <Blacksmoke16> `Proc(Nil).new do `*
<Reiser> Yes! Wonderful, thanks Blacksmoke
<FromGitter> <Blacksmoke16> although im not sold on if this really needed?
<Reiser> I don't know, so many other languages allow for throwaway scopes for doing work like this, I wouldn't say It's needed
<Reiser> But it doesn't feel so great having to define methods for single time throwaway calls just to avoid having to come up with a lot of non-conflicting variable names
<FromGitter> <Blacksmoke16> :shrug: cant say i never had a need to dod that
<FromGitter> <Blacksmoke16> to do*
<FromGitter> <Blacksmoke16> dont happen to have some example code of when this would be useful?
<FromGitter> <Blacksmoke16> like in crystal lang
<FromGitter> <Blacksmoke16> land*
<Reiser> Sure, I'll share what I'm writing in a moment if you're still around in 15 minutes
<FromGitter> <Blacksmoke16> 👍
renich has joined #crystal-lang
<Reiser> @Blacksmoke16: https://paste.rs/FNh.rb
<Reiser> Something like this
<Reiser> I have to fetch a few different things through an application that are all called proposals, and It's nice to be able to just re-use the variable names without worrying about the type unions growing out of control
renich has quit [Ping timeout: 240 seconds]
<Reiser> I also don't need the variables after so it feels kind of messy to have, val_proposals, prop_proposals hanging around through the whole script
<Reiser> Of course you don't have to code this way, I just prefer to I guess 🤷‍♂️
<Reiser> It's common in Rust
<FromGitter> <Blacksmoke16> yea i guess i would try to do OOP it a bit more, versus just doing everything on the top level
<FromGitter> <Blacksmoke16> like maybe use a module and class methods
<FromGitter> <Blacksmoke16> just as a way to namespace/isolate the stuff
<Reiser> I'm not a fan of OOP when all it does is namespace something, It's a pretty imperative script
<Reiser> But yeah, different styles
<FromGitter> <Blacksmoke16> or really its prob not a big deal if you redefine a variable later on
<FromGitter> <Blacksmoke16> id imagine the compiler is smart enough to handle that
<Reiser> I just don't want to have to deal with is_a?() randomly, but yeah, true
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/9s6o
<Reiser> Oh wow
<Reiser> I underestimated the compiler
<Reiser> I assumed it just grew out the union over time
<Reiser> I guess it does flow analysis
<FromGitter> <Blacksmoke16> naw, new value new type
<Reiser> Very cool, first week with Crystal so It's all a bit new
<FromGitter> <Blacksmoke16> can also restrict a local var to a specific type via like `foo : Int32 = 1`
<Reiser> Trying it out as an alternative to ugly bash scripts
<FromGitter> <Blacksmoke16> wouldn't compile if you then tried to do `foo = "foo"`
<FromGitter> <Blacksmoke16> imo wouldnt ruby be better in that regard? if you dont need perf having something that doesnt need to compile might be easier to work with
<Reiser> Compilation is actually what's making this easier, I have to deploy this into a pretty bare-bones image that I'm not allowed to install new system packages onto, but I can deploy binaries to
<FromGitter> <Blacksmoke16> if the script is small, otherwise having a single binary that you can move around is also nice
<Reiser> Yeah
<FromGitter> <Blacksmoke16> 👍
<Reiser> `crystal x.cr` is turning out to be plenty fast for iteration also
<FromGitter> <Blacksmoke16> not terrible yea, gets worse as it gets bigger, and when you introduce the release flag
<FromGitter> <Blacksmoke16> but when you get it to a final state ofc just do an actual release build once and then you dont have to worry about it
renich has joined #crystal-lang
<FromGitter> <asterite> blocks create a scope: if you declare a variable inside them (which isn't yet outside them) then the variable won't exist outside of the block. No need to use Proc or captured blocks
<FromGitter> <asterite> So I guess you could do something like `def scope; yield; end`. Then use it like `scope { a = 1; whatever }; # a doesn't exist here`
<FromGitter> <Blacksmoke16> any thoughts on how to handle this? https://play.crystal-lang.org/#/r/9s6t
<FromGitter> <Blacksmoke16> type of `validated_by` i think is being reduced causing it not match the correct overload
renich has quit [Ping timeout: 240 seconds]
<FromGitter> <asterite> it won't work because it's a bug
<FromGitter> <asterite> Compare this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f7777a0fcce3e6c18eadad4]
<FromGitter> <Blacksmoke16> 😢 rip. I guess i need to think of plan b
<FromGitter> <Blacksmoke16> is there already an issue for that/
pciuch9 has joined #crystal-lang
<pciuch9> hello
<FromGitter> <Blacksmoke16> o/
<pciuch9> why crystal not using 'if...then' format?
<pciuch9> i would like to write if in one line
<FromGitter> <Blacksmoke16> `expression ? true_value : false_value`?
<FromGitter> <Blacksmoke16> `true_value if expression`
<pciuch9> ugly and not readable if using many || &&
<pciuch9> very difficult moving from ruby
<FromGitter> <Blacksmoke16> what are you trying to port? got some example code?
<pciuch9> my code ;-) I wrote in ruby and would move it to crystal
<pciuch9> trouble is with types (default or not) and with 'then'
<FromGitter> <Blacksmoke16> got some example code of the trouble parts?
f1refly has quit [Quit: bye fags]
f1refly has joined #crystal-lang
sorcus has joined #crystal-lang
pciuch9 has quit [Ping timeout: 260 seconds]
pciuch9 has joined #crystal-lang
<pciuch9> if trouble || nottrouble then make.size else make.other end
DTZUZU_ is now known as DTZUZU
<FromGitter> <mgomes> You can use the ternary operator mentioned above: `trouble || not_trouble ? make.size : make.other`
<pciuch9> if superhiper then a;b ; c; k; dd end
renich has joined #crystal-lang
renich has quit [Ping timeout: 240 seconds]
<FromGitter> <Blacksmoke16> solution here is to just not do that
<FromGitter> <Blacksmoke16> just because crystal shares ruby syntax doesn't mean you should expect it to be 100% BC
<FromGitter> <Blacksmoke16> with Ruby
<FromGitter> <Blacksmoke16> `a; b; c if true` is valid code fwiw
<FromGitter> <Blacksmoke16> so not really a big change required there anyway
<pciuch9> syntax is very important when I must convert a programs
<FromGitter> <Blacksmoke16> right, but there are bound to be changes you'll need to make in order to get it to work
<FromGitter> <Blacksmoke16> having syntax similar to ruby helps reduce the amount, but there are still most likely going to be issues that'll need resolved
<pciuch9> this is trouble for me
<FromGitter> <Blacksmoke16> so to be clear you dont like that you'll have to change your Ruby program in order to make it work in Crystal?
<pciuch9> I wrote ruby before crystal exist
<FromGitter> <Blacksmoke16> so?
<FromGitter> <Blacksmoke16> Sorry, I'm just trying to understand what the problem is
pciuch9 has quit [Ping timeout: 240 seconds]
renich has joined #crystal-lang
renich has quit [Quit: Leaving.]
renich has joined #crystal-lang
renich has quit [Ping timeout: 256 seconds]