<FromGitter>
<Blacksmoke16> functionaly it works yea, but still messing with the implementation details
<FromGitter>
<Blacksmoke16> might refactor how im building out the params
<FromGitter>
<Blacksmoke16> is getting a bit too complex now to keep everything in order
<FromGitter>
<dscottboggs_gitlab> yeah working in macro land on something that complex can get super messy
<FromGitter>
<Blacksmoke16> well that portion isnt really in macro land
<FromGitter>
<Blacksmoke16> way things work atm the string params are added to an array
<FromGitter>
<Blacksmoke16> but those params have to get added in right order to match the method params
<FromGitter>
<Blacksmoke16> and the method params have to be in right order to match route params, request body, then query params
<FromGitter>
<Blacksmoke16> its a catch 22
<FromGitter>
<Blacksmoke16> i cant auto build out routes based on method arg names/types since i dont know where they go
<FromGitter>
<Blacksmoke16> and i cant build out method params/names since i dont know the types
<FromGitter>
<Blacksmoke16> would be nice if order of method params didnt matter, will have to see if i can think of something
<FromGitter>
<dscottboggs_gitlab> wow that sounds tough
<FromGitter>
<Blacksmoke16> :shrug: I have some ideas
<FromGitter>
<Blacksmoke16> See how it goes :p
<FromGitter>
<Blacksmoke16> Anyway, off to bed o/
<FromGitter>
<dscottboggs_gitlab> sleep well
<FromGitter>
<Blacksmoke16> Well going to write this in case I forget before I go to bed :p
<FromGitter>
<dscottboggs_gitlab> yeah, famous last words
<FromGitter>
<dscottboggs_gitlab> 3 hours later
<FromGitter>
<dscottboggs_gitlab> 😆
<FromGitter>
<Blacksmoke16> Think I can just use parameter name in route to match with method param names, would require route and action names to match, which is IMO a good thing
<FromGitter>
<Blacksmoke16> And just always call the request body, body
<FromGitter>
<Blacksmoke16> So then order you define parameters in doesn't matter
<FromGitter>
<Blacksmoke16> Ok, night :p
<FromGitter>
<dscottboggs_gitlab> good night, good luck!
rohitpaulk has quit [Remote host closed the connection]
DTZUZO has quit [Ping timeout: 246 seconds]
DTZUZO has joined #crystal-lang
jemc has quit [Ping timeout: 268 seconds]
marmotini_ has joined #crystal-lang
marmotini has joined #crystal-lang
marmotini_ has quit [Client Quit]
fanta7531 has quit [Quit: ...]
zolbatar has joined #crystal-lang
zolbatar has quit [Client Quit]
ashirase has quit [Ping timeout: 258 seconds]
ashirase has joined #crystal-lang
[spoiler] has quit [Ping timeout: 264 seconds]
[spoiler] has joined #crystal-lang
fanta7531 has joined #crystal-lang
laaron has quit [Remote host closed the connection]
<FromGitter>
<girng> good morning! ready for some crystal coding today am hyped
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter>
<diegogub_gitlab> Hello all..I'm keep reading from @asterite to stop using NamedTuples. I wanted to do some functional programming in Crystal, and I cannot see better fit than NamedTuples to pass data around.
<FromGitter>
<diegogub_gitlab> Should I use them everywhere?
<FromGitter>
<girng> did you stumble upon that SO question lol
<FromGitter>
<girng> i did, too. was surprised he said that
<FromGitter>
<girng> but he's prob right...
<FromGitter>
<drum445> @diegogub_gitlab generally anonymous objects aren't ideal, but if you are using them for small or no processing it's fine
<FromGitter>
<drum445> Everything has a use case
<FromGitter>
<drum445> But nothing suits all of them
<FromGitter>
<diegogub_gitlab> @drum445 I'm mostly using aliases to NamedTuples..and pass them around functions. Merging them and so on..would that give me any memory leak?
<FromGitter>
<drum445> I wouldn't think it would cause a memleak, if you're passing them around a lot I would probably suggest using a class. If you're dealing with JSON you can use Class.from_json. ⏎ Classes are also safer as you won't run into key errors
<FromGitter>
<diegogub_gitlab> @drum445 I guess so, class without public properties would be safer. Thanks!
<FromGitter>
<girng> @diegogub_gitlab i use namedtuples with `to_json` in a tick rate on my gameserver. ran it for a couple hours, etc no memory leak. for example, in my client Class: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c407bbd95e17b452566d0c9]
<FromGitter>
<drum445> Yeah exactly, I'd recommend a look into the SOLID principles
<FromGitter>
<diegogub_gitlab> @girng I will do some testing..
laaron has quit [Remote host closed the connection]
<FromGitter>
<Blacksmoke16> @dscottboggs_gitlab it was actually surprisingly easy...took like 2min lol
<FromGitter>
<girng> gn
<jokke>
hey
<jokke>
is it possible to build html instead of xml using the XML.build method? (or any other method)
marmotini has quit [Ping timeout: 250 seconds]
Creatornator has joined #crystal-lang
laaron has joined #crystal-lang
<FromGitter>
<j8r> I don't succeed how to `{{debug}}` `class_getter?`, does anyone know how to do?
<FromGitter>
<j8r> I try to know how works `(class_)getter? do ... end` because calling the getter doesn't seems to do anything...
<FromGitter>
<AllanKlaus> Hey guys, I'm think in develp an appplication in my company using crystal and amber, it will go to production and interact receiving request from other apis and accessing database. ⏎ ⏎ Do you think crystal is stable to use with a framework to do it?
trashhalo[m] has quit [Ping timeout: 252 seconds]
trashhalo[m] has joined #crystal-lang
jemc has joined #crystal-lang
jemc has quit [Client Quit]
jemc has joined #crystal-lang
spacemanspam has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<Blacksmoke16> long as you keep up to date/aware of breaking changes it shouldnt be a big issue
Creatornator has joined #crystal-lang
<FromGitter>
<waghanza> Hi @/all, any idea about next release date ?
<FromGitter>
<AllanKlaus> @Blacksmoke16 is hard to keep the last version updated?
<FromGitter>
<Blacksmoke16> i more so meant, be aware of upcoming changes, and dont blindly update
<FromGitter>
<Blacksmoke16> on debian its just `apt update && apt upgrade`
<FromGitter>
<dscottboggs_gitlab> and the included module would intercept the request at some point? that's great
<FromGitter>
<Blacksmoke16> which would plop in a global (in this case) handler that would parse out a bearer token from request headers and set a `current_user` var, so then in all your actions would have access to `self.current_user` for custom auth or whatever
<FromGitter>
<Blacksmoke16> security module is on my list but would require some hashing out to figure out how i want it to work
<FromGitter>
<Blacksmoke16> :shrug: see how it goes, am sure some other people here would have some feedback on how to best handle it
<FromGitter>
<dscottboggs_gitlab> I really need to set aside some time to look over how Athena works, it seems pretty cool
<FromGitter>
<Blacksmoke16> annotations and structs for the most part
<FromGitter>
<Blacksmoke16> use structs as the payload of the router, which stores static data defined from the annotations at compile time
<FromGitter>
<Blacksmoke16> so only thing that happens at runtime is route matching and param conversion
<FromGitter>
<Blacksmoke16> what have you been working on lately?
<FromGitter>
<dscottboggs_gitlab> Spent some time learning a bit of C++, Qt, reading the Rust book, and finishing up some demo projects so that hopefully I can get a job soon
<FromGitter>
<dscottboggs_gitlab> I've been writing some Go the past couple days and it's so limiting next to crystal
<FromGitter>
<Blacksmoke16> ah nice, good luck
<FromGitter>
<Blacksmoke16> every lang i look at just doesnt look appealing compared to crystal for sure :p
<FromGitter>
<dscottboggs_gitlab> thanks, I gotta go for a bit, I'll be on later though
<FromGitter>
<Blacksmoke16> o/
spacemanspam has quit [Read error: Connection reset by peer]
spacemanspam has joined #crystal-lang
spacemanspam has quit [Read error: Connection reset by peer]
<FromGitter>
<elorest> `File.write("/dev/ttyUSB0", "\x05\x40\x10\x08\xA3".to_slice)` also works. I'd think it should be possible without closing the IO every time though.
CommanderViral has joined #crystal-lang
<FromGitter>
<girng> possible to convert a boolean value to 1 or 0 based on true or false?
<FromGitter>
<elorest> bool ? 0 : 1
<FromGitter>
<maiha> @elorest `usb0.print` rather than `puts` ?
<FromGitter>
<girng> @elorest ty
<FromGitter>
<elorest> @maiha thanks. I tried, puts, write, <<, etc
<FromGitter>
<maiha> ok. And two points. `IO#flush` and `open(..., "w")` ?
<FromGitter>
<elorest> I'm trying to read responses as well which is why I used `a+`
<FromGitter>
<Blacksmoke16> its literally the same thing
<oprypin>
you're so hopeless
<FromGitter>
<Blacksmoke16> what?
<FromGitter>
<elorest> @girng I think `#to_unsafe` implies something untrue in this case
<FromGitter>
<elorest> It's not returning a pointer or something.
spacemanspam has joined #crystal-lang
<FromGitter>
<Blacksmoke16> should be named `.to_i` imo
<FromGitter>
<Blacksmoke16> nothing unsafe about it
<oprypin>
we have a function that is meant for C bindings interoperation, which, even though it's not named like what you want to do, happens **at the moment** to do what you want
<oprypin>
if there was a `to_i` then you might use it, but there isn't, and it isn't about naming, it's about entirely different purposes
<oprypin>
you don't just go around using **unsafe** things because they **at the moment** have a piece of code that you like
<FromGitter>
<Blacksmoke16> then replace `to_unsafe` with `to_i` and implement that in the future
<FromGitter>
<Blacksmoke16> problem solved
<oprypin>
it is not a replacement because `to_unsafe` has special interactions with C bindings
<FromGitter>
<Blacksmoke16> fair enough
<FromGitter>
<girng> i agree, naming is important. going back to ternary
<FromGitter>
<girng> i'm sorry
<FromGitter>
<Blacksmoke16> should at least add a note to the docs then
<FromGitter>
<Blacksmoke16> makes it seem like thats what its mean to do
<oprypin>
yes. and (technically) yes
<FromGitter>
<Blacksmoke16> ill make a PR for `to_i` seems like it would be useful
<FromGitter>
<maiha> @elorest `print` is wrong. It should be `write`, sorry. It seems `usb0.close` is essential at last.
<FromGitter>
<Blacksmoke16> esp since the other method is special, can prob nodoc it at that point, otherwise would be even more confusing
<oprypin>
maiha, `print` seemed odd to me, but i started digging and i thought that it ended up doing the same thing anyway
<oprypin>
regarding the previous - sorry for my tone.
<FromGitter>
<elorest> @maiha Ah ok. Thats what I was afraid of. Thanks.
Raimondi has joined #crystal-lang
<FromGitter>
<maiha> Yep. Both `> foo` on shell and `File.write` would call `fclose(3)`. 😺