<FromGitter>
<dscottboggs_gitlab> this is why people hate JS
<FromGitter>
<dscottboggs_gitlab> anyway, is there any way to access annotations on arbitrary constant values (i.e. an enum variant)
<FromGitter>
<Blacksmoke16> idt
<FromGitter>
<dscottboggs_gitlab> fucks sake
<FromGitter>
<Blacksmoke16> sec
<FromGitter>
<Blacksmoke16> yea no
<FromGitter>
<dscottboggs_gitlab> do you think a PR would be accepted adding that? I think it could cause side-effects either way...If constant names are a new macro type, that's a breaking change. OTOH, adding annotation checking to everything that's a`MacroID`might not be good either...
<FromGitter>
<Blacksmoke16> whats the use case?
<FromGitter>
<dscottboggs_gitlab> I have an enum for which I want to override the string representation of some of them. β β Wait....JSON::Field does this somehow...
<FromGitter>
<dscottboggs_gitlab> no that's on ivars
<FromGitter>
<Blacksmoke16> override `to_json` within the enum
<FromGitter>
<Blacksmoke16> is prob what you would have to do
<FromGitter>
<straight-shoota> `From IRC` is a bot that bridges messages between gitter and IRC. The message was sent by erdnaxeli via IRC
<FromGitter>
<phykos> mh ok
<FromGitter>
<tenebrousedge> you can't do destructuring assignment in a Proc literal, right?
fifr has joined #crystal-lang
<fifr>
Hi, I have a question: why does 'a = [1]; a[0..] = [1, 2]' work but 'a = [] of Int32; a[0..] = [1,2]' or 'a = [] of Int32; a[..] = [1,2]' do not? Is this intended?
<FromGitter>
<Blacksmoke16> easier to see the errors and such
<FromGitter>
<tenebrousedge> the error is because in the other examples a[0] doesn't exist
<FromGitter>
<tenebrousedge> so you get an index out of bounds
<FromGitter>
<tenebrousedge> I think that's more-or-less intentional
<FromGitter>
<tenebrousedge> if you think that *should* be possible, you might make an issue
<FromGitter>
<tenebrousedge> I'm not sure how much support you'd get
<fifr>
Well, imho it should work if replacing an empty range is ok, in particular the last example (but also in the second example the range 0.. is empty for that array)
<FromGitter>
<tenebrousedge> replacing a range where the first element doesn't exist provokes an index out of bounds error
<fifr>
yes, I know (or that's what I assume what happens in these examples) ... the question is whether it should be that way
<fifr>
I think one can argue if this makes sense for explicit indices ... but what about the last example with the unbounded range?
<FromGitter>
<kinxer> @fifr Why should the language allow `a[..] = [1, 2]` when that is exactly the same as `a = [1, 2]`?
<FromGitter>
<kinxer> The second option is shorter and more clear.
<FromGitter>
<tenebrousedge> I think it's consistent. This isn't Ruby, where accessing unset elements returns `nil`. Also , I don't think the unbounded range is actually unbounded as applied to this context
<FromGitter>
<Blacksmoke16> `Because the begin and end are now optional, we can also write (..). It doesn't have much use, really. We could forbid it. But right now you can use it:`
<FromGitter>
<tenebrousedge> arrays start at 0
<fifr>
kinxer: it is? I thought that `a = [1,2]` create a *new* array, whereas `a[..] = [1,2]` should *replace* the content of the array
<fifr>
i.e. after something like `a = []; b = []; a[..] = [1,2]` the two variables should still refer to the same array
<hypercore>
what's method do you guys usually use for building binaries? i'm from the dynamic language world, so i've never really had to do this before, and am not really sure about best practices in this regard
<fifr>
that's actually the reason how I came to this question
<FromGitter>
<kinxer> @fifr That's a fair distinction. Okay, then, in order for the behavior of `a[]` to be consistent, `a[..] = [1,2]` should replace all elements of `a` with the array `[1,2]`. If `a` is empty, there are no elements to replace and therefore, by trying to replace an element, you would get an `IndexOutOfBoundsException`.
<FromGitter>
<tenebrousedge> fifr that example declares two empty arrays
<FromGitter>
<tenebrousedge> maybe you meant `b = a` ?
<fifr>
ah, sorry, I mean `a = []; b = a`, yes
<hypercore>
also i want to run them on the smallest VPS possible, but i think i need at least 2GB to build crystal binaries, so i'm having to pay for a more expensive vps. It would be good if i could build the binaries somewhere else, and then upload it to my 1GB server
<FromGitter>
<tenebrousedge> fifr if you want to replace the entire array, there is `array#replace`
<fifr>
kinxer: well, it's a philosphical question if you can replace "nothing" by "something" ;)
<FromGitter>
<tenebrousedge> it would be in Ruby, but in Crystal we throw an exception if you try to access elements that don't exist
<fifr>
tenebrousedge: sure ... but `a[..]` is valid and does not fail because, well, we only access the empty range hence we do not really access a non-existing element ... anyway, I just wanted to raise question, thanks for the discussion
<FromGitter>
<vlazar> I think there are many others or you can build your own docker container
<FromGitter>
<asterite> I think the array .. thing is a bug. Please report it
<hypercore>
thanks vlazar, i'll give it a try
absolutejam has quit [Ping timeout: 265 seconds]
<FromGitter>
<kinxer> @fifr You brought the question; you want to make the GitHub issue?
Nekka has quit [Ping timeout: 240 seconds]
Nekka has joined #crystal-lang
absolutejam has joined #crystal-lang
absolutejam has quit [Ping timeout: 276 seconds]
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
absolutejam has joined #crystal-lang
dostoyevsky has quit [Quit: leaving]
dostoyevsky has joined #crystal-lang
dostoyevsky has quit [Quit: leaving]
dostoyevsky has joined #crystal-lang
Seich has quit [Remote host closed the connection]
<FromGitter>
<ImAHopelessDev_gitlab> > @absolutejam_gitlab the scary thing is crystal can be written to be just as confusing or worse β > β > ``` β > newVal = val.class == "SomeClass" ? sanitize_SomeClass(val) { raise "error handling here because why not" } : val β > ``` ... [https://gitter.im/crystal-lang/crystal?at=5da77fd6894dee56e555c725]
<FromGitter>
<ImAHopelessDev_gitlab> Yeah, what happens to `newVal`, when the exception happens
<FromGitter>
<absolutejam_gitlab> well if it's unhandled, nothing?
<FromGitter>
<tenebrousedge> things go splodey
<FromGitter>
<absolutejam_gitlab> If it is handled, it gets raised to the handling block anyway?
<FromGitter>
<absolutejam_gitlab> Dunno, just guessing here
Seich has joined #crystal-lang
<FromGitter>
<tenebrousedge> I think you're right. `newVal` would go out of scope
<FromGitter>
<tenebrousedge> it wouldn't be initialized
<FromGitter>
<absolutejam_gitlab> the more I toy with the likes of Go and JS, the more I appreciate the constructs available in Crystal's stdlin
<FromGitter>
<absolutejam_gitlab> Sure, Go has a comprehensive stdlin for other stuff, like SSH
<FromGitter>
<absolutejam_gitlab> stdlib*
<FromGitter>
<tenebrousedge> JS is Just Sad
<FromGitter>
<absolutejam_gitlab> it really is the worst
<FromGitter>
<absolutejam_gitlab> The front-end devs I work with don't even defend it, they just respond with 'yeah, you just get used to that kinda shit'
ht_ has quit [Remote host closed the connection]
<FromGitter>
<ImAHopelessDev_gitlab> Yeah I'm a front-end dev, I feel the same way. However, vanilla JS will always be in my heart, and sometimes I might feel like I need to defend it (dependent on my mood)
<FromGitter>
<marynowac> Hi, β I came across a problem with the database connection. A standard piece of code: β β ```DB.open "postgres://myuser:mypasswd@remoteserver/mydb" do |db| β # some code β end``` β ... [https://gitter.im/crystal-lang/crystal?at=5da78955870fa33a4d05379e]
<erdnaxeli>
It's related to your database configuration
<erdnaxeli>
There must be a way in the code to change the authentication type
<erdnaxeli>
Here you are trying to use a clear auth, wich your database configuration does not allow
<FromGitter>
<marynowac> I have no influence on the database configuration.
<FromGitter>
<marynowac> I did some tests and I successfully connect there using php. But not Crystal.
<erdnaxeli>
Yep, it's your code that need to be fixed. I'm looking at the doc but it don't see how yet π€
<FromGitter>
<marynowac> Me too. What's reason why I asked you for help :)
<FromGitter>
<marynowac> @ImAHopelessDev_gitlab β It seems that clear text auth is removed from the driverβ¦
<FromGitter>
<ImAHopelessDev_gitlab> @marynowac i wonder why, is it a security issue?
<FromGitter>
<marynowac> Don't know. I'm a hopeless dev too :-]
<FromGitter>
<ImAHopelessDev_gitlab> π
Nekka has quit [Ping timeout: 268 seconds]
Nekka has joined #crystal-lang
<FromGitter>
<phalcondroid> Hi Guys, im going to start to develop an application with an administrator and api, i was temped to use amber for both functionalities but i don't sure if i can develop the api with amber too, do you think its better for API other framework as Kemal?
<FromGitter>
<phalcondroid> or use amber only for web admin?
<FromGitter>
<sam0x17> you could pretty easily use amber for an API -- just inherit from one ApiController where you specify that it should use JSON etc
<FromGitter>
<sam0x17> on my app I went all kemal, though
Nekka has quit [Ping timeout: 240 seconds]
Nekka has joined #crystal-lang
<FromGitter>
<phalcondroid> and is good the amber performance?
<FromGitter>
<Blacksmoke16> prob good enough
<FromGitter>
<Blacksmoke16> anything crystal is going to be decent enough for real world use
<FromGitter>
<Blacksmoke16> is also Athena, however its quite young. depending on how it will be used might not be the best choice
<FromGitter>
<sam0x17> lucky has really good docs and is similar to amber
<FromGitter>
<sam0x17> I'm not using any of them though until they strip out the (optional) nodejs dependency by default and replace it with something like https://github.com/sam0x17/html-minifier
<FromGitter>
<Blacksmoke16> dont have a nodejs dep if you dont render any html π
<FromGitter>
<sam0x17> true dat
<FromGitter>
<sam0x17> I saw a website back in the day that was a dynamically generated (php) gif with image maps defining all the navigation
<FromGitter>
<phalcondroid> Guys do you think is a good choice amber/crystal to production application?
<FromGitter>
<ImAHopelessDev_gitlab> yeah
<FromGitter>
<phalcondroid> haha thanks, just the nudge that i need
<FromGitter>
<ImAHopelessDev_gitlab> :D
<FromGitter>
<ImAHopelessDev_gitlab> Are you starting something fresh? Or converting an old codebase into Crystal?
<FromGitter>
<phalcondroid> i have an administrator of my application actually in phalcon/php is good and i liked but, i would try on crystal i think it is very awesome
<FromGitter>
<ImAHopelessDev_gitlab> noicee
<FromGitter>
<phalcondroid> but I don't want to lose my job and migration of code if the language and framework are not yet mature
<FromGitter>
<ImAHopelessDev_gitlab> LOL
<FromGitter>
<ImAHopelessDev_gitlab> haha i feel ya
absolutejam has quit [Ping timeout: 240 seconds]
hypercore has quit [Ping timeout: 260 seconds]
<FromGitter>
<Blacksmoke16> @tenebrousedge you'd prob have a thought on this
<FromGitter>
<Blacksmoke16> would you expect a logger to make it `[2019-10-16T23:33:43.733675000Z] main.INFO: STRING` (imagine thats colored) be colored if logging to STDOUT, but strip the colorize chars if logged to a file
<FromGitter>
<Blacksmoke16> (or if anyone else has thoughts)
<FromGitter>
<Blacksmoke16> i can either:
<FromGitter>
<Blacksmoke16> 1) Just strip all colors (easiest) β 2) Try and do something hacky to support this
hypercore has joined #crystal-lang
<FromGitter>
<Blacksmoke16> im leaning towards one, just to keep things simple and not like you're going to be watching logs
<FromGitter>
<tenebrousedge> I think you could try to detect whether the output was going to a terminal that supports colors
<FromGitter>
<tenebrousedge> I'd do the hacky thing
<FromGitter>
<Blacksmoke16> problem is, currently a logged message is a string, so id have to go and add `Colorize::Object(String)` and carry that around
<FromGitter>
<tenebrousedge> oh, you went and put type restrictions in your code?
alexherbo2 is now known as alex```
<FromGitter>
<Blacksmoke16> (this is for my logging shard)
<FromGitter>
<tenebrousedge> I mean, a colorized string is still a string, it just has escape sequences in it
<FromGitter>
<Blacksmoke16> exactly, but since its a string i cant just do `str.toggle(false)` anymore