ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.31.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <Blacksmoke16> @tenebrousedge thought of a better implementation for the colorize things i think
* FromGitter * tenebrousedge is curious
<FromGitter> <Blacksmoke16> handlers could do `include Colorizable` which i could then do like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5daba5784bc69e6b6605bf57]
<FromGitter> <tenebrousedge> Why a class test and not a predicate method?
<FromGitter> <Blacksmoke16> this falls down since IO an handler files and STDOUT
<FromGitter> <Blacksmoke16> can handle*
<FromGitter> <Blacksmoke16> was thinking since a handler is specific to one particular thing that either will or won't support colorized strings
<FromGitter> <Blacksmoke16> er i see your point
<FromGitter> <Blacksmoke16> ```def supports_colorize? ⏎ xxx ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5daba671714b8b0538236c39]
<FromGitter> <tenebrousedge> right
<FromGitter> <Blacksmoke16> i like that better
<FromGitter> <tenebrousedge> `Colorize` doesn't have such a predicate, but Crystal has open classes
<FromGitter> <tenebrousedge> alternately there seems to be this: ⏎ https://github.com/crystal-lang/crystal/blob/master/src/colorize.cr#L128
<FromGitter> <Blacksmoke16> dont think that would work?
<FromGitter> <tenebrousedge> I suspect you're right
<FromGitter> <Blacksmoke16> because im wrapping IOs in a class vs using them directly
<confact> Is it any way to generate a self-signed SSL certificate in crystal's stdlib? Can't find that.
<FromGitter> <tenebrousedge> and the class doesn't expose the IOs via delegation?
<FromGitter> <Blacksmoke16> naw, its private to the handler
<FromGitter> <Blacksmoke16> confact im not sure, if anything it would be in the `OpenSSL` module
<FromGitter> <ImAHopelessDev_gitlab> @ilanpillemer what is the editor you use called again? i had some memory issues last night, vscode was hovering around 500mb of ram when i had 10 cr files open. was just too much. ⏎ i raged, and then just started to code in notepad. felt kinda cool, but missed the format on save
<FromGitter> <Blacksmoke16> 😕
<FromGitter> <tenebrousedge> @ImAHopelessDev_gitlab acme
<FromGitter> <tenebrousedge> it's from Plan 9
<FromGitter> <tenebrousedge> I'd also look into spacevim (https://spacevim.org/)
<FromGitter> <Blacksmoke16> yea might go with a module that ill include in the processing handler (that allows for formatters), that will default to false, but allow children to override it
<FromGitter> <Blacksmoke16> i.e. ⏎ ⏎ ```!@io.is_a? File``` [https://gitter.im/crystal-lang/crystal?at=5daba7a84bc69e6b6605d243]
<FromGitter> <Blacksmoke16> er
<FromGitter> <Blacksmoke16> `@io.tty?` would prob be better
<FromGitter> <tenebrousedge> probably
<FromGitter> <Blacksmoke16> i could go with that, if a user wants they can also reopen and define their own logic
<FromGitter> <ImAHopelessDev_gitlab> @tenebrousedge oh yeah, ACME. thanks gonna give it a try now.
<FromGitter> <watzon> Lol 500MB really isn't that bad for something that's almost an IDE
<FromGitter> <tenebrousedge> if you only have 500MB it might be a lot
<FromGitter> <Blacksmoke16> who only has 500mb of ram
<FromGitter> <watzon> If you only have 500MB you've got bigger issues
<FromGitter> <Blacksmoke16> what they doing on, an RPI1?
<FromGitter> <Blacksmoke16> coding*
<FromGitter> <Blacksmoke16> `String#delete` should have an overload for `Regex`
<FromGitter> <tenebrousedge> I'm sure I don't know. But I'd still go with spacevim. I need syntax highlighting
<FromGitter> <watzon> Right now I have Code and PyCharm open. Code is hovering around 330MB and PyCharm is using about 1.1GB
<FromGitter> <watzon> SpaceVim is nice
<FromGitter> <tenebrousedge> @Blacksmoke16 it does patterns. `gsub(//, '')` should do for the rest
<FromGitter> <tenebrousedge> not that I necessarily disagree, mind
<FromGitter> <ImAHopelessDev_gitlab> I really miss Notepad++. I used that editor for years when I was younger
<FromGitter> <tenebrousedge> bluefish is pretty similar
<FromGitter> <ImAHopelessDev_gitlab> Never heard of bluefish, I'll google it
<FromGitter> <ImAHopelessDev_gitlab> Wow, it is, nice
<FromGitter> <tenebrousedge> let me know how similar you find it; I used it for a while, but by the time I started coding I was off Windows, so I have no direct comparisons myself
<FromGitter> <ImAHopelessDev_gitlab> @tenebrousedge I'm back to vscode. I don't think i'll be able to change atm, vscode is instilled in my mind pretty hard, it will be hard to let it go.
<FromGitter> <tenebrousedge> what features do you miss?
<FromGitter> <ImAHopelessDev_gitlab> Just the look and UI, it's all comfortable and stuff I'm used to
<FromGitter> <sam0x17> same for me
<FromGitter> <sam0x17> if I even change syntax highlighting themes it looks like a different language to me
<FromGitter> <tenebrousedge> huh
<FromGitter> <sam0x17> I actually use the atom one dark theme in vscode
<FromGitter> <sam0x17> because I used atom forever
<FromGitter> <sam0x17> I'm very fussy about how things look :P
<FromGitter> <ImAHopelessDev_gitlab> @sam0x17 When I used notepad++ way back when I was a kid (14-15 to until 25 or so), I tried switching to a new editor and could never do it. I finally had to when I started to use Crystal though because of the format on save hahah.
<FromGitter> <sam0x17> lolz
<FromGitter> <ImAHopelessDev_gitlab> I tried so many editors... could never get away from Notepad++ ahhaha
<FromGitter> <sam0x17> I've basically been Eclipse (java and C++) => Atom => vscode (over the course of 10 years)
<FromGitter> <sam0x17> with nano randomly thrown in for things like git commits and when I'm starting a new project before I've opened it in an IDE
<FromGitter> <tenebrousedge> I rather like nano. It does syntax highlighting, too, if you enable it
<FromGitter> <sam0x17> after 12 years of coding I'm happy to say I now how to escape from VI/VIM if it opens
<FromGitter> <sam0x17> *know
return0e_ has quit [Remote host closed the connection]
<FromGitter> <sam0x17> xD
<FromGitter> <sam0x17> yeah the syntax highlighting is nice
<FromGitter> <tenebrousedge> I picked up vim this year. spacevim anyway
<FromGitter> <sam0x17> I've always wanted to try making a vscode-style terminal IDE, with mouse support etc
<FromGitter> <tenebrousedge> and switched to vim bindings in VSCode
<FromGitter> <sam0x17> the killer feature for vscode over atom was the built in terminal pane
<FromGitter> <sam0x17> vs in atom I had to use addons (that failed a lot) to do that
<FromGitter> <tenebrousedge> you'd love spacevim then
<FromGitter> <sam0x17> probably
<FromGitter> <tenebrousedge> `SPC + '` opens the terminal
<FromGitter> <tenebrousedge> and you have the full vim-powered copy and paste
<FromGitter> <sam0x17> I just can't with the keyboard shortcuts but I did try to learn vim once
<FromGitter> <tenebrousedge> there's a built-in tutorial, and spacevim is pretty good at reminding you what's what
<FromGitter> <tenebrousedge> if you just hit `SPC` and wait a second it shows all possible commands, and you can then drill down through the menus
<FromGitter> <sam0x17> vscode drives me nuts with its autocompletions
<FromGitter> <sam0x17> tbh
<FromGitter> <sam0x17> that and it sucks at properly indenting copy pasted code
<FromGitter> <sam0x17> does everything else right though
<FromGitter> <sam0x17> atom was better at formatting arbitrary languages
<FromGitter> <tenebrousedge> vscode has good test runners
<FromGitter> <tenebrousedge> maybe even great test runners
<FromGitter> <sam0x17> I haven't used that but I can imagine -- the tooling for java and C++ is very good
<FromGitter> <tenebrousedge> and completion for javascript is waaaaaay better
<FromGitter> <sam0x17> yes
<FromGitter> <sam0x17> though the only thing I ever need js completion for is to remember if its `.startsWith` or `.startWith`
<FromGitter> <watzon> Trump voice: *VS Code has great test runners. They are probably the best test runners I've ever seen. They wouldn't have such tremendous test runners if it wasn't for me.*
<FromGitter> <tenebrousedge> with React I need all the help I can get
* FromGitter * sam0x17 skitters back into his cave *eek react*
<FromGitter> <watzon> That's because react sucks
<FromGitter> <watzon> *Runs*
<FromGitter> <sam0x17> the 3 times I've almost had to react I made my own half-baked js framework instead
<FromGitter> <sam0x17> *to use react
<FromGitter> <sam0x17> been thinking of using svelte though
<FromGitter> <sam0x17> or vue, but svelte looks really interesting
<FromGitter> <sam0x17> I just want to avoid npm
<FromGitter> <sam0x17> tho
<FromGitter> <watzon> That's because React is a *build your own framework* kit. It's not a framework itself, just a library.
<FromGitter> <tenebrousedge> I don't really care about react *per se*, but redux is fairly important to me
<FromGitter> <watzon> Svelte is nice, but I don't feel like it's super ready yet. I love Vue though.
<FromGitter> <tenebrousedge> the last time someone told me to work without redux I simply reimplemented it from scratch
<FromGitter> <sam0x17> I have only gone deep enough to know that redux is the "state management" stuff
<FromGitter> <sam0x17> and its funny because I managed a team that was doing a react app
<FromGitter> <tenebrousedge> it's "state only changes in specific ways" stuff
<FromGitter> <tenebrousedge> which is the useful bit
<FromGitter> <sam0x17> I've just never understood the itch all that stuff is trying to scratch
<FromGitter> <tenebrousedge> was your JS dealing with a remote API?
<FromGitter> <sam0x17> yes, always
<FromGitter> <tenebrousedge> implementing more than one API call is pretty much where I want state handling
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <sam0x17> I just usually have a client-side `api.js` file with centralized "request" method that includes re-logging in, session management, error handling logic, and then have a bunch of methods that use that method to define different endpoints
<FromGitter> <sam0x17> and then the ensuing callback hell xD
<FromGitter> <tenebrousedge> right, that :/
<FromGitter> <Blacksmoke16> https://github.com/crystal-lang/crystal/issues/8353 if anyone has some thoughts
<FromGitter> <tenebrousedge> not at this hour of night
<FromGitter> <tenebrousedge> you're familiar with phpdoc and yard?
<FromGitter> <Blacksmoke16> phpdoc moreso than yard
<FromGitter> <Blacksmoke16> trying to find an example of how they render it
<FromGitter> <sam0x17> my main question would be could we generate the list of exceptions statically
<FromGitter> <sam0x17> cuz that would be handy
<FromGitter> <tenebrousedge> that sounds probable
<FromGitter> <sam0x17> I bet there are contrived examples where it is more difficult
<FromGitter> <tenebrousedge> how?
<FromGitter> <sam0x17> not sure
<FromGitter> <Blacksmoke16> being able to parse out `raise xxx` from a method would be ideal
<FromGitter> <tenebrousedge> macro generated methods maybe?
<FromGitter> <Blacksmoke16> would loose the desc tho
<FromGitter> <sam0x17> that or things with polymorphism where I'm writing Foo, and someone in another shard is going to use Foo in their Bar, and a method of Foo might call a method of Bar that in turn throws an exception only Bar knows about
<FromGitter> <sam0x17> so aka which exceptions show up might change depending on third party code
<FromGitter> <sam0x17> but generally yeah I think we could do it statically
<FromGitter> <sam0x17> no idea if crystal provides enough introspection to do it, but I did some similar static analysis of C++ code a few years ago and yeah you could def do this at compile time
<FromGitter> <Blacksmoke16> dunno, the `RAISES: ` syntax would prob be much easier to implement
<FromGitter> <sam0x17> ah, here is your contrived example @tenebrousedge: ⏎ `raise error_array[File.read("path").to_i]`
<FromGitter> <tenebrousedge> what even is that?
<FromGitter> <sam0x17> you have an array of different error types, and you raise one based on a number saved in a file that is an index into the array
<FromGitter> <tenebrousedge> make it stop :(
<FromGitter> <sam0x17> or something like `raise [err1, err2, err3].sample`
<FromGitter> <sam0x17> xD
<FromGitter> <ImAHopelessDev_gitlab> Working on Simple and lightweight Crystal Text Editor https://i.gyazo.com/4f5ac27ea93d0f77834764a529f72e0d.mp4. Next step is implementing format on save using crystal format
<FromGitter> <tenebrousedge> `raise .sample` ?!! you sadist
<FromGitter> <sam0x17> hah
<FromGitter> <sam0x17> .sample is a fun quick way to mess with staticly doable stuff
<FromGitter> <sam0x17> crystal is very susceptible because everything is an object so you can sample almost anywhere
<FromGitter> <tenebrousedge> my mind is not that twisted :(
<FromGitter> <tenebrousedge> good lord that would be awful to debug
<FromGitter> <sam0x17> it gets better you could include random modules in a macro I believe
<FromGitter> <sam0x17> tho you might have to make sample available manually
<FromGitter> <sam0x17> then you would have different compiler errors each time
<FromGitter> <sam0x17> I literally think I would make that a homework assignment if I ever taught crystal in a PL class
<FromGitter> <sam0x17> "write a program that compiles correctly 72% of the time on average"
<FromGitter> <tenebrousedge> what would that teach?
<FromGitter> <sam0x17> a certain way of thinking
teardown has joined #crystal-lang
<FromGitter> <sam0x17> hmm looks like macro system aggressively prevents the use of random
<FromGitter> <sam0x17> could read from `/dev/random` though
<FromGitter> <tenebrousedge> maybe as an extra credit assignment. Usually programming curricula are pretty crowded
f1refly has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 264 seconds]
return0e has joined #crystal-lang
<FromGitter> <sam0x17> here we go chaotic module including: ⏎ https://play.crystal-lang.org/#/r/7uco
<FromGitter> <sam0x17> (you have to make a change to the file or playground will just use cached output looks like)
return0e has quit [Ping timeout: 240 seconds]
<FromGitter> <tenebrousedge> that gives me a sad :(
<FromGitter> <sam0x17> lol
<FromGitter> <sam0x17> naw its just cool how theoretically powerful the macro system is
<FromGitter> <sam0x17> its like excel, if you bother hard enough you can implement an artifical neural network in it xD
<FromGitter> <tenebrousedge> or a flight simulator
<FromGitter> <sam0x17> if it compiles, you landed successfully xD
chemist69 has quit [Ping timeout: 245 seconds]
chemist69 has joined #crystal-lang
teardown has quit [Quit: leaving]
teardown has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <bajro17> @watzon svelte is really awesome I was work before with vue but now I completely switch to svelte
_whitelogger has joined #crystal-lang
return0e has joined #crystal-lang
absolutejam2 has joined #crystal-lang
return0e has quit [Ping timeout: 265 seconds]
<FromGitter> <absolutejam_gitlab> Svelte looks interesting
ht_ has joined #crystal-lang
DTZUZO has quit [Ping timeout: 240 seconds]
dwdv has joined #crystal-lang
absolutejam2 has quit [Ping timeout: 240 seconds]
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
alexherbo2 has joined #crystal-lang
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 265 seconds]
dwdv has quit [Read error: Connection reset by peer]
ua has quit [Ping timeout: 250 seconds]
dwdv has joined #crystal-lang
return0e has joined #crystal-lang
ua has joined #crystal-lang
<FromGitter> <ilanpillemer> @ImAHopelessDev_gitlab it is a completely different paradigm to menu driven (eg vscode) and also char driven (eg emacs, vi). It also expects an understanding of *ix as a programming environment,
<FromGitter> <ilanpillemer> There is a very sharp learning curve
<FromGitter> <ilanpillemer> it is *very* niche.
<FromGitter> <ilanpillemer> there is however a dedicated long standing community around it
<FromGitter> <ilanpillemer> and luminaries such as Russ Cox, Rob Pike, Ken Thompson, Ritchie, Stroustrup do use it. https://news.ycombinator.com/item?id=12063178
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 276 seconds]
DTZUZO has joined #crystal-lang
_whitelogger has joined #crystal-lang
absolutejam2 has joined #crystal-lang
chemist69 has quit [Quit: WeeChat 2.3]
absolutejam2 has quit [Ping timeout: 268 seconds]
go|dfish has joined #crystal-lang
<FromGitter> <ilanpillemer> the way Crystal shadows parameters with local variables of the same name I find frustrating
<FromGitter> <Blacksmoke16> Ameba catches that
<FromGitter> <ilanpillemer> I find it frustrating as I don’t want it to shadow
<FromGitter> <ilanpillemer> and its a problem especially when using the Top namespace
<FromGitter> <ilanpillemer> I cant even get around it `count = count`
<FromGitter> <Blacksmoke16> @kinxer https://www.youtube.com/watch?v=hPvh6UgJtRw
absolutejam2 has joined #crystal-lang
absolutejam2 has quit [Ping timeout: 250 seconds]
<FromGitter> <sam0x17> @ilanpillemer you can always use `self.` to disambiguate, as people do in java
<FromGitter> <sam0x17> on the topic of js frameworks, I wrote this for work and intend to clean it up and make it actually nice at some point: https://github.com/sam0x17/conduit
<FromGitter> <sam0x17> designed for deploying to S3 / cloudfront --- you set up `/*` to redirect to `/router.html` on the cloudfront side, and then javascripts handles all the routing from there. All views are pre-compiled to a compressed hash in the `router.html`, and body contents get swapped out (similar to rails's turbolinks) whenever a link to a routing path is pressed, so you effectively get instant page loads. Then you hook it
<FromGitter> ... up to a lambda-based API server, and you're 100% serverless with instant page loads
<FromGitter> <sam0x17> works great if you have under 200 unique view templates, over that it's better to split it into multiple routers
<FromGitter> <sam0x17> I need to invent a component paradigm for it as well -- my usage has just been basic jquery-ish API stuff, directly changing dom elements and contents
<FromGitter> <sam0x17> it's also designed with a hatred and avoidance of NPM xD
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
alexherbo2 has joined #crystal-lang
alexherbo23 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo237 has joined #crystal-lang
alexherbo237 has quit [Client Quit]
alexherbo2 has joined #crystal-lang
alexherbo23 has quit [Ping timeout: 250 seconds]
Nekka has quit [Ping timeout: 240 seconds]
Nekka has joined #crystal-lang
duane has joined #crystal-lang
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
absolutejam2 has joined #crystal-lang
hightower3 has joined #crystal-lang
<FromGitter> <ilanpillemer> most package systems seem quite dangerous
<FromGitter> <ilanpillemer> what do you think of the go.sum, go.mod and proxy approach?
<FromGitter> <absolutejam_gitlab> it still feels gross but it's a billion times better than the shit show that Go package management has been
<FromGitter> <absolutejam_gitlab> the weird patching package versions is a bit unclear but it seems to work
<FromGitter> <ilanpillemer> https://research.swtch.com/deps
rohitpaulk has joined #crystal-lang
<FromGitter> <ilanpillemer> yes. in many ways I find it sucks.. but yet I do believe its the most secure package system I have ever used.. and hence the best.
<FromGitter> <ilanpillemer> so what I guess I am asking is what do you think of it in terms of the secureness and dependability and trustworthiness.
<FromGitter> <absolutejam_gitlab> Oh, I see. Yeah, most package systems are pretty ropey to be honest
<FromGitter> <ilanpillemer> for example.. so guy can just delete a dependency or change it.
<FromGitter> <absolutejam_gitlab> Github being a source of truth and no guarantees of MFA, authenticity, etc.
<FromGitter> <ilanpillemer> yes, the famous left trim from npm for example
<FromGitter> <absolutejam_gitlab> But I've published something on PyPi just for ease of use - not really for public consumption - and it's suddenly a thing
<FromGitter> <absolutejam_gitlab> I prefer systems that refer to packages as `<owner>/<package>` than jus `<package>`
<FromGitter> <ilanpillemer> what did you publish?
<FromGitter> <absolutejam_gitlab> It was just to test creating a PyPi package
<FromGitter> <ilanpillemer> and now its depended on by others?
<FromGitter> <absolutejam_gitlab> Was it Steam that released a deb that did essentially did a `rm -rf `because of a bad variable?
<FromGitter> <absolutejam_gitlab> some big package did it
<FromGitter> <absolutejam_gitlab> or a browser perhaps
<FromGitter> <absolutejam_gitlab> and that was in the debian repos iirc
<FromGitter> <ilanpillemer> there was also one that just snuck in bitcoin mining
<FromGitter> <absolutejam_gitlab> yeah, snap, npm, and other package managers have had that
<FromGitter> <absolutejam_gitlab> > and now its depended on by others? ⏎ ⏎ No, thankfully not, but it was super easy I mean
<FromGitter> <absolutejam_gitlab> and i didn't have to verify any kind of authenticity
<FromGitter> <absolutejam_gitlab> and I used the word 'azure' in it
<FromGitter> <ilanpillemer> so.. is there Crystal package manager.
<FromGitter> <absolutejam_gitlab> So somebody could have
<FromGitter> <absolutejam_gitlab> `shards` is the crystal package manager
<FromGitter> <ilanpillemer> and how does it make it things trust worthy?
<FromGitter> <ilanpillemer> Ive become paranoid lately, so I only depend on things that are significant, others I reinvent the wheel.
<FromGitter> <absolutejam_gitlab> > the way Crystal shadows parameters with local variables of the same name I find frustrating ⏎ ⏎ What do you mean by this btw?
<FromGitter> <absolutejam_gitlab> It doesn't afaik
<FromGitter> <ilanpillemer> eg
<FromGitter> <absolutejam_gitlab> It's another 'pull from Git' package manager
<FromGitter> <absolutejam_gitlab> The best thing you can do is pin at a version and fork
<FromGitter> <absolutejam_gitlab> then you're responsible for it
<FromGitter> <absolutejam_gitlab> it's what I do at work for dependencies
<FromGitter> <absolutejam_gitlab> instead of vendoring
<FromGitter> <ilanpillemer> ```func append(a, b) ⏎ a … (this a is not that a) ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5dacb5f6714b8b05382acafb]
<FromGitter> <absolutejam_gitlab> Was going to ask if you've been writing Go 👅
<FromGitter> <absolutejam_gitlab> Oh god, that's not the emoji Iw as looking for
<FromGitter> <ilanpillemer> I wrote go all day.
<FromGitter> <ilanpillemer> in the evenings, Crystal at the moment
<FromGitter> <ilanpillemer> I intend to learn many languages over the next 12 months
<FromGitter> <ilanpillemer> I want to become very polyglot
<FromGitter> <absolutejam_gitlab> Your `def foo(a, b)` example - Doesn't that just depend on the input value? I didn't see anything weird about it
<FromGitter> <ilanpillemer> the a inside is a local variable
<FromGitter> <ilanpillemer> its not the a that came in
<FromGitter> <ilanpillemer> so if you an a on the lhs, in may situations you will get a rude shock
<FromGitter> <absolutejam_gitlab> Can you give me an example?
<FromGitter> <ilanpillemer> it seems on the rhs, though the a is the one that came in
<FromGitter> <ilanpillemer> very simple example
<FromGitter> <ilanpillemer> ```def append(items, item) ⏎ items << item ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5dacb7ad714b8b05382ad64a]
<FromGitter> <absolutejam_gitlab> Because I'm thinking about the variable type that comes in to the function - a String/Integer (etc.) doesn't get mutated whereas an Array or a class object will
<FromGitter> <ilanpillemer> now items is a reference
<FromGitter> <ilanpillemer> but the items you pass in wont get appended to
<FromGitter> <ilanpillemer> as the one on the left is a new items
<FromGitter> <ilanpillemer> a local variable that shadows the argument
<FromGitter> <ilanpillemer> I keep getting caught out by different cases
<FromGitter> <absolutejam_gitlab> I'm still not understanding
<FromGitter> <absolutejam_gitlab> https://play.crystal-lang.org/#/r/7uf5
<FromGitter> <absolutejam_gitlab> It's probably me
<FromGitter> <ilanpillemer> change
<FromGitter> <ilanpillemer> ```items = items << item``` ⏎ ⏎ to [https://gitter.im/crystal-lang/crystal?at=5dacb88624af474d28e684ab]
<livcd> i cant wait to replace my go services with Crystal
<FromGitter> <ilanpillemer> ```items = items + item```
<FromGitter> <watzon> `items += item`
<FromGitter> <ilanpillemer> in your version you also mutated the incoming one
<FromGitter> <watzon> @absolutejam_gitlab you're trying to append and return a new array rather than appending to the referenced array?
<FromGitter> <absolutejam_gitlab> oh, I assumed because of the same name...
<FromGitter> <ilanpillemer> yes.
<FromGitter> <absolutejam_gitlab> so, in your example why wouldn't you have `new_items = items + item`?
<FromGitter> <ilanpillemer> I believe `ameba` reports these
<FromGitter> <absolutejam_gitlab> or am I still confused haha
<FromGitter> <ilanpillemer> its just simpe example
<FromGitter> <absolutejam_gitlab> Sunday night is not a time for my brain to work, and I'm just not understanding the issue, sorry haha.
<FromGitter> <watzon> It has to be `items = items + [item]` though
<FromGitter> <absolutejam_gitlab> Yeah ^
<FromGitter> <ilanpillemer> right
<FromGitter> <watzon> The `+` is a concatenation operator, not appending
<FromGitter> <absolutejam_gitlab> You need to add another array with that syntax right
<FromGitter> <absolutejam_gitlab> Plus I have a very narrow view of languages, so what I expect is what the few languages I've dealt with have shown me
<FromGitter> <ilanpillemer> so the `why` is not important
<FromGitter> <watzon> You can also say ⏎ ⏎ ```items = items.dup ⏎ items << item``` [https://gitter.im/crystal-lang/crystal?at=5dacba09c86aec24c67a98a3]
<FromGitter> <ilanpillemer> but you cant say
<FromGitter> <ilanpillemer> `items = items`
<FromGitter> <ilanpillemer> I tried that
<FromGitter> <Blacksmoke16> what are you trying to do?
<FromGitter> <tenebrousedge> you can do `items.replace(items)`
<FromGitter> <ilanpillemer> it changes at different times
<FromGitter> <ilanpillemer> what I want to do
<FromGitter> <tenebrousedge> or `items[..] = items`
<FromGitter> <ilanpillemer> if its an array you can
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <ilanpillemer> what if its an int
rohitpaulk has quit [Ping timeout: 265 seconds]
<FromGitter> <tenebrousedge> `+=`
<FromGitter> <ilanpillemer> yeah.. that would work. a bit confusing to read
<FromGitter> <ilanpillemer> I think I got an error too
<FromGitter> <ilanpillemer> as it was not declared
<FromGitter> <ilanpillemer> cant remember now
<FromGitter> <ilanpillemer> I think I tried that
<FromGitter> <tenebrousedge> most of my `ints` are produced by `count`, I think
<FromGitter> <ilanpillemer> I have been caught by it three times nows in different contexts
<FromGitter> <ilanpillemer> does Ruby do the same thing?
<FromGitter> <absolutejam_gitlab> are we talking about mutating the input variable?
<FromGitter> <ilanpillemer> I think its this
<FromGitter> <absolutejam_gitlab> In Golang and languages of that kin where you explicitly pass by value or ref vs. the Pythons and Rubys of the world where you have to know if the input variable is mutable or not
<FromGitter> <tenebrousedge> Ruby does do the same thing, essentially. It's technically pass-by-reference, but shadowing is allowed
<FromGitter> <ilanpillemer> Go is bit tricky as slices are different to arrays
ht_ has quit [Remote host closed the connection]
alexherbo2 has joined #crystal-lang
<FromGitter> <lbarasti> @firejox et al, PR to add docs to Channel#send and Channel#close: https://github.com/crystal-lang/crystal/pull/8356
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dacce99714b8b05382b86b8]
<FromGitter> <ilanpillemer> Is there a better idiomatic way of doing this?
<oprypin> ummmmmmm doing what
<oprypin> theres some trickery with stringscanner that i cant grasp. dont mind me
<FromGitter> <tenebrousedge> Why not use a class or struct?
<FromGitter> <tenebrousedge> why don't you have the same love affair with `Iterator` that I do?
<oprypin> whaaa. iterators really suck to write in Crystal
<FromGitter> <tenebrousedge> ....no
<FromGitter> <tenebrousedge> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dacd17df3f2b34d27cea44d]
<FromGitter> <oprypin> ```code paste, see link``` ⏎ ⏎ ¯\\\_(ツ)_/¯ [https://gitter.im/crystal-lang/crystal?at=5dacd2a4dd688b6b67056493]
<FromGitter> <ilanpillemer> @oprypin it counts the size of a decompressed string
<FromGitter> <ilanpillemer> which has to be recursively expanded
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dacd3300fdc4b6507235c2d]
<FromGitter> <ilanpillemer> with this input
<FromGitter> <ilanpillemer> I originally decompressed the string itself.. which kind of failed.
<FromGitter> <ilanpillemer> As its bigger than a number that can be represented by Int32
<FromGitter> <ilanpillemer> so this version just counts the size as streams through the decompressed string
<FromGitter> <ilanpillemer> I got to learn about StringScanner too, which was nice
<oprypin> is `s.offset += num_letters` even correct here
<FromGitter> <tenebrousedge> @oprypin that's not an iterator
<oprypin> tenebrousedge, why yes it is
<FromGitter> <ilanpillemer> yes,, because the scanner then moves you across the decompression instructions
<FromGitter> <tenebrousedge> no, taking a block does not make it an iterator
<FromGitter> <ilanpillemer> as the instructions are not part of the decompressed string
<oprypin> tenebrousedge, sorry this is Python
<FromGitter> <ilanpillemer> so embed a string scanner in an iterator?
<FromGitter> <tenebrousedge> it's been done
<FromGitter> <tenebrousedge> see my Forth and protein translation
<oprypin> it doesnt add any utility here tho
<oprypin> iterators are nice for being able to pause them, but this is too simple for that
<FromGitter> <tenebrousedge> I'm convinced you write bad code now
<FromGitter> <ilanpillemer> 🙈
<FromGitter> <ilanpillemer> I thought iterators were nice for infinite things
<FromGitter> <ilanpillemer> as they are lazy
<FromGitter> <ilanpillemer> if you have to go to end anyways...
<FromGitter> <tenebrousedge> you can use them for infinite sequences. You can also wrap `while` loops with them
<FromGitter> <tenebrousedge> which allows you to apply higher-order iterators to unknown-length sequences
<FromGitter> <ilanpillemer> *off to look at the protein translation*
<FromGitter> <ilanpillemer> hmm.. can’t.. *looks at Forth instead*
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
<oprypin> ilanpillemer, one sugesstion - it's arguable if it's an improvement, because it's slightly harder to follow, but it's more efficient and less repetition. make `decom` accept a `ss : StringScanner` and `num_letters`. then you dont create any new stringscanners and eliminate the redundant advancing the old one as well
<oprypin> then `def decom(s : String): decom(StringScanner.new(s), s.size)`
<oprypin> actually maybe the *current* one is harder to follow because it made me ask the question :D
<FromGitter> <ilanpillemer> hmm
<FromGitter> <ilanpillemer> if its more efficient and less repetitive its an improvement
<FromGitter> <ilanpillemer> does `+=` mutate?
<FromGitter> <ilanpillemer> or does it shadow?
<FromGitter> <tenebrousedge> mutate
<FromGitter> <ilanpillemer> why do you have to have a space before the `:` for types?
<FromGitter> <ilanpillemer> is that because `:` is a valid char in a variable name?
<oprypin> it was just decided that way.
<oprypin> it used to be allowed in distant past.
<oprypin> finally found it
sagax has quit [Ping timeout: 240 seconds]
<FromGitter> <ilanpillemer> I keep forgetting the space.
<FromGitter> <ilanpillemer> The formatter then reminds me
<FromGitter> <didactic-drunk> What chance is there of getting `ctime` and `birth_time` exposed in `File::Info` if I submit a PR? `st_ino` and `st_dev`?
<FromGitter> <Blacksmoke16> id prob make an issue first, then go from there
mps has left #crystal-lang [#crystal-lang]
<FromGitter> <ImAHopelessDev_gitlab> @ilanpillemer thanks for the info ⏎ @ilanpillemer what does "crystal shadows parameters with local variables of the same name" mean? Is there an example code of this and what are the side effects?
<FromGitter> <tenebrousedge> if you have ⏎ ⏎ ```def foo(bar) ⏎ bar = 123 ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5dacea6224af474d28e7f0a8]
<FromGitter> <tenebrousedge> then `bar` will be a local variable with the value 123, and not whatever value was passed in
<FromGitter> <tenebrousedge> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5daceac1e3646f24c761700a]
<FromGitter> <tenebrousedge> inside the method, `a` is a new local variable. Since it has the same name as the outer variable, we say that it is "shadowing" the outer variable
<FromGitter> <tenebrousedge> if instead you use `a += bar + [1]` then you are mutating the outer variable
<FromGitter> <ImAHopelessDev_gitlab> I see, so it's important to have local variables not the same name as the parameter names?
<FromGitter> <tenebrousedge> the `ameba` tool will tell you not to do that, correct
<FromGitter> <tenebrousedge> it causes confusion and bugs
absolutejam2 has quit [Ping timeout: 268 seconds]
<FromGitter> <ImAHopelessDev_gitlab> Wait really
<FromGitter> <ImAHopelessDev_gitlab> "mutating the outer variable"
<FromGitter> <ImAHopelessDev_gitlab> that doesn't sound good
<FromGitter> <tenebrousedge> generally I would avoid trying to change variables that are not defined in the current scope
hightower3 has quit [Ping timeout: 240 seconds]
<Stephanie> llvm 9 support seems to be about a +2 line diff
<Stephanie> which is, nice
<Stephanie> and a refreshing change haha
<FromGitter> <tenebrousedge> for sure