<BlaXpirit>
though it might also be a harmless change to stdlib to have it like that
<FromGitter>
<drosehn> Ah, yeah, that gives me some interesting ideas. thanks.
soveran has quit [Remote host closed the connection]
shawn42 has quit [Quit: Connection closed for inactivity]
bjz has joined #crystal-lang
Philpax has quit [Ping timeout: 260 seconds]
perks has quit [Quit: perks]
emancu has joined #crystal-lang
bjz has quit [Read error: Connection reset by peer]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 256 seconds]
pduncan has joined #crystal-lang
<FromGitter>
<drosehn> Hmm. I wonder if there is some max-depth or something with JSON's `mapping()` macro. It turns out that the JSON in my source files is pretty complicated. It's impressive how flexible `mapping()` is, and how it's able to handle *almost* everything I need.
<FromGitter>
<drosehn> I'm down to one last variable, which needs to be `v: String | Nil`. If I define it as just `v: String`, everything works except that there are three records in my source file which do not have this `v:` value defined.
<FromGitter>
<drosehn> But if I *do* define it as `v: String | Nil`, then those same three lines run into an error of `Error: couldn't parse (String | Nil) from 1359608400 at 0:0`.
<FromGitter>
<drosehn> I have plenty of other entries defined as `something: String | Nil`, and all of those work fine. I've even copied-and-pasted one of those lines into this call to `mapping()` (from a call in a different class), and then changed 'something' to 'v', and it still fails.
<FromGitter>
<drosehn> But my program is already doing much better than I expected it to do, and I don't really care about the JSON fields which end up in this class. So I just commented out the `v: String | Nil` line, and turned `strict:` off for the`mapping()` of this class.
<FromGitter>
<drosehn> Unfortunately my data files include a lot of sensitive info, so it'd be way too much work for me to come up with an example.
<FromGitter>
<cjgajard> Did you tried using `v: {type: String, nilable: true}` instead of `v: String | Nil`??
<FromGitter>
<cjgajard> nope, sorry, "Passing T | Nil as a type has the same effect"
<FromGitter>
<drosehn> I did try that just in case it was some obscure bug, but I did end up with the same errors.
<FromGitter>
<drosehn> (I certainly don't know enough about crystal macros to try and debug this!)
<FromGitter>
<drosehn> Hmm. I should probably enter this as an "issue" on github, but I've been too much of a pest in the last few days. Maybe in a few days, if I can't come up with any insights on it.
<FromGitter>
<drosehn> g'night...
snsei has joined #crystal-lang
emancu has quit [Ping timeout: 244 seconds]
pawnbox has joined #crystal-lang
soveran has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
soveran has quit [Ping timeout: 256 seconds]
pawnbox has joined #crystal-lang
pawnbox_ has joined #crystal-lang
pawnbox has quit [Ping timeout: 265 seconds]
emancu has joined #crystal-lang
pawnbox_ has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pduncan has quit [Ping timeout: 240 seconds]
soveran has joined #crystal-lang
bjz has joined #crystal-lang
bjz has quit [Read error: Connection reset by peer]
soveran has quit [Ping timeout: 256 seconds]
bjz has joined #crystal-lang
bjz has quit [Read error: Connection reset by peer]
bjz has joined #crystal-lang
emancu has quit [Ping timeout: 245 seconds]
soveran has joined #crystal-lang
emancu has joined #crystal-lang
<FromGitter>
<choallin> Hey folks! Since I am talking a look into FP languages as well right now I was wondering how well Crystal is handling FP style. ⏎ I know it has many of the features that Ruby has and therefore it works with that style as well, but I'm wondering how efficient Crystal is if I'm using e.g. a lot of recursion and stuff like this. Are there any information about that? :smile:
snsei has quit [Remote host closed the connection]
pawnbox has quit [Remote host closed the connection]
akwiatkowski has joined #crystal-lang
pawnbox has joined #crystal-lang
mark_66 has joined #crystal-lang
bjz_ has joined #crystal-lang
snsei has joined #crystal-lang
bjz has quit [Ping timeout: 244 seconds]
snsei has quit [Ping timeout: 258 seconds]
pawnbox has quit [Read error: Connection reset by peer]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
hako has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
<FromGitter>
<mverzilli> hi @choallin, if you go that way you'll be wrestling a lot with the language features and the std lib design. not that I don't like FP (on the contrary, I love it!), but Crystal is designed as an imperative OOP language from the ground up
<FromGitter>
<mverzilli> there are some features from FP that you could mimic in Crystal (like currying) but that's about it. if you're looking for a language somehow resembling Ruby that embraces FP maybe you can give Elixir a try
hako has quit [Ping timeout: 260 seconds]
hako_ has joined #crystal-lang
soveran has quit [Remote host closed the connection]
<FromGitter>
<choallin> Thanks for the answer @mverzilli ⏎ I don't want do use Crystal as a full blown FP language but these days I often find myself writing (business logic) code that is stateless and has as few side effects as possible. To do this, I use the FP methods that are build in Ruby (map, reduce,...) and are also there in Crystal. But also I like to write some loops as recursions since this appears more natural too me. So, I was wondering
<FromGitter>
... if there are any tail recursion optimizations made in Crystal. :smile:
<FromGitter>
<greentornado> Is there any eventbus for crystal
<BlaXpirit>
and what would that be
<txdv>
its a bus for events
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
Philpax has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 256 seconds]
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
shawn42 has joined #crystal-lang
Philpax has quit [Ping timeout: 260 seconds]
soveran has quit [Remote host closed the connection]
perks has joined #crystal-lang
snsei has joined #crystal-lang
emancu has quit []
Raimondii has joined #crystal-lang
Raimondi has quit [Remote host closed the connection]
<FromGitter>
<paulcsmith> The model_class appears to be a `Path`, but I'd like to treat it as the constant so I can access the `FIELDS` constant. Any ideas how to do that?
<FromGitter>
<paulcsmith> I've tried a few things, but haven't been able to figure it out :S
<FromGitter>
<paulcsmith> I can do `model_class.resolve` which returns the constant (at least that's what appears to happen), but then I still get the "unexpected token" error. Maybe there is a method for getting a constant instead of using `::`?
<BlaXpirit>
paulcsmith, you can't put :: after a lowercase identifier
<BlaXpirit>
so what you're trying to do is probably impossible
<BlaXpirit>
but it seems to be just names of constants..?
<FromGitter>
<paulcsmith> Yeah I think you're right. It seems you can't use `::` after lower case as you said. I was hoping there was a method that would allow me to do something similar, but maybe not :(
<RX14>
BlaXpirit, but you get a constant node which has the full path which can then be pasted
<BlaXpirit>
true, good idea
<BlaXpirit>
can't iterate over those FIELDS though
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 256 seconds]
<FromGitter>
<paulcsmith> Yeah I'm trying to iterate over the fields :S Haven't been able to find away to do that
<FromGitter>
<redcodefinal> Good morning Crystal community. May your code be type safe, readable, and polymorphic in these trying times.
<FromGitter>
<philnash> 🙌
<FromGitter>
<paulcsmith> Good morning to you too @redcodefinal!
Renich has joined #crystal-lang
<FromGitter>
<redcodefinal> Hey, readability question, how much do we frown upon monkey patching? I want to add a "make_nd_array" method that makes a Nd Array.
<FromGitter>
<sdogruyol> @redcodefinal it is OK
<FromGitter>
<redcodefinal> Actually, I'm having a little trouble wrapping my head around the generic types in this. I'm trying to make a method that makes a 2d array, and takes a block to define each default value. ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ It fails because it can't figure out what T is supposed to be. [https://gitter.im/crystal-lang/crystal?at=5824c1dadf5ae966453e8c13]
<FromGitter>
<cjgajard> @samueleaton , IMHO spawn outside methods is better because it make them testable synchronously and I only have to care about synchronization in one place. (and the `spawn method` macro makes it pretty)
<FromGitter>
<samueleaton> @cjgajard agreed! Thats is what I ended up doing.
<BlaXpirit>
these are entirely different concurrency concepts...
<FromGitter>
<samueleaton> Yup. just going on a tangent.
<FromGitter>
<cjgajard> `async def` is quite useless, but it is easy to make :-P ( https://carc.in/#/r/1doi )
<BlaXpirit>
:P
rafadc has joined #crystal-lang
<FromGitter>
<redcodefinal> So I've been looking through the docs and I noticed there is a ```map``` but not a ```map!``` which should modify the object it's referencing. Is there a reason behind this?
<FromGitter>
<johnjansen> it gets tricky when the collection becomes mutable apparently
<FromGitter>
<johnjansen> e.g. consider `[1,2,3].map!(&.to_s)`
<FromGitter>
<redcodefinal> damn didnt think of that
<FromGitter>
<redcodefinal> there are so many habits and ways of thinking I got from Ruby I need to change for Crystal
<FromGitter>
<johnjansen> just remember, its not ideal to change the type of a variable … it becomes less predictable
<FromGitter>
<redcodefinal> Do you think there is good way to make the ```set_all``` method as described in that link?
<FromGitter>
<johnjansen> there is alot of bad ruby around, i tripped over a very well used method in a ruby gem the other day which returned `(Array(String) | String | Int32 | Nil)`how this ever worked was pure luck
<FromGitter>
<redcodefinal> oh ok thats how thanks @BlaXpirit
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 256 seconds]
FromGitter has quit [Ping timeout: 268 seconds]
FromGitter has joined #crystal-lang
BlaXpirit has quit [Ping timeout: 265 seconds]
<FromGitter>
<redcodefinal> idk. I'm pretty much building it whole, then testing all the individual pieces to make sure they work. A lot of things have to change because Ruby had it's way of doing things that Crystal doesn't. I also built a viewer last time but I might skip that until the last step. I'll probably just make it output PNGs
BlaXpirit has joined #crystal-lang
<FromGitter>
<sdogruyol> Well if you can actually build and run it then that's a win. Isn't it?
<FromGitter>
<redcodefinal> yeah thats the hope but I feel it's very optimistic.
<FromGitter>
<redcodefinal> There is a lot I'm not sure if I am doing right, or stuff that I think is right that is wrong. All I can say, hope the debugging will be easy.
<FromGitter>
<sdogruyol> Well we can help you and learn / improve together
<FromGitter>
<redcodefinal> hell yeah. I love the gitter we have and the conversation and helpfulness of this community
<FromGitter>
<sdogruyol> That makes me happy :)
<FromGitter>
<wmoxam> anyone know of any work on a gui toolkit shard?
<FromGitter>
<redcodefinal> Can I make a method definition for an abstract definition? Essentially ensuring it can't be used until it has been inherited?
<FromGitter>
<redcodefinal> I wanted to force someone to define it when inheriting the class, but not allow it to be directly called from the super class
<Papierkorb>
redcodefinal, an abstract class can never bee instantiated directly?
<FromGitter>
<wmoxam> @sdogruyol ohh, interesting
* FromGitter
* wmoxam checks for openbsd support
<FromGitter>
<redcodefinal> I wasnt even thinking about abstracting the class itself. Just a method in a class that shouldn't be called directly, but needs an additional definition
<FromGitter>
<wmoxam> ah it's a wrapper over gtk 3
<FromGitter>
<redcodefinal> @johnjansen if I am not mistaken,. which I very well might be, one letter class names are not allowed
<FromGitter>
<redcodefinal> @BlaXpirit do you remember that github issue you sent me where they discussed making a forall?
<FromGitter>
<johnjansen> @redcodefinal they are allowed
<FromGitter>
<redcodefinal> ah I remember reading in the github issue where they added forall they were talking about disabling the one letter class names and let them be used for generics only
<mgarciaisaia>
It seems to be an issue with autotools or something like that. The maintainer tried to clearly explain the issue, but I still don't get what should I do. I'm stalled trying to install Crystal from sources there :/
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 258 seconds]
<FromGitter>
<redcodefinal> When defining a method that takes a block if I ```typeof``` the block variable I get ```Proc(Nil)```. What does the Nil mean here?
<FromGitter>
<barisbalic> To those who may be interested, I finally had time to sort out Crystal Docs, it now pulls repos from GH on first request, then attempts to update them every 30 minutes or so. It takes the latest 6-7 crystal releases and tries to build against those. It looks for new releases every hour. I think @RX14 this is something you specifically preferred?
<RX14>
ehh
<FromGitter>
<barisbalic> RX14 like a month ago or whenever I pushed the original crystal docs you said you'd prefer for it to pull from GH and build, rather than be a glorified rsync server. Just letting you know that's now the case.
<RX14>
well i rather liked the option for both
<FromGitter>
<barisbalic> @RX14 would you care to elaborate over DM?
<RX14>
and how do you solve the building issue?
<RX14>
containers?
<FromGitter>
<barisbalic> As I said above, I just keep a bunch of crystal releases, then attempt to build in order of version descending, until the list is exhausted
<RX14>
yes but how do you make sure people can't run RCE against the build server?
<RX14>
generating the docs still runs macros which runs remote code on your machine with full shell access
mgarciaisaia has left #crystal-lang [#crystal-lang]
<RX14>
what do you do?
<FromGitter>
<barisbalic> @RX14 I don't, I had assumed (without checking) that building the docs was safe, however now that I think about it I can't see how it could be.
bjz has joined #crystal-lang
<FromGitter>
<barisbalic> I don't really want to get tangled up in docker, at the same time the rsync option meant it was hard to restrict what was uploaded, and supporting both users/CI publishing was non-trivial.
soveran has joined #crystal-lang
bjz has quit [Read error: Connection reset by peer]
<Papierkorb>
barisbalic, you really should use containers, or maybe systemd-nspawn, to limit the power of the ran crystal commands. Everything else is a ticking bomb waiting for someone to turn your server into a private proxy or a botnet zombie or something
<FromGitter>
<barisbalic> @Papierkorb, yeah that's obvious now
<FromGitter>
<barisbalic> I guess docker it is
<Papierkorb>
Please make sure to read the docker manuals in its entirety
<Papierkorb>
Docker is a container service to easily deploy things, it's not really a security service in itself
rafadc has quit [Ping timeout: 244 seconds]
<FromGitter>
<barisbalic> It is very unlikely I'll do that, I'll likely do nothing for another month, I have little time as it is.
Renich has quit [Quit: leaving]
<Papierkorb>
It's a bit like using chroot() for security reasons. Yes, it has been done, and it has always been wrong too for the general case
soveran has quit [Remote host closed the connection]
lacour has joined #crystal-lang
<RX14>
using docker AND making the command run as an unprivileged user inside docker gives good protection