RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.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
briank has joined #crystal-lang
<watzon> Two new crystal projects in one day :)
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
maattdd has joined #crystal-lang
snsei has quit [Ping timeout: 256 seconds]
maattdd has quit [Ping timeout: 256 seconds]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<watzon> Crap. The case statement doesn't do fallthrough does it?
<FromGitter> <bew> What do you mean by "fallthrough"?
<watzon> In some languages, it seems java-type languages in particular, the switch/case statement will allow conditions to "fall through" if there isn't a break. So one thing will match and, if there isn't an explicit break, the next thing that matches will also be called
<watzon> Ruby doesn't do it and I guess Crystal doesn't either
<watzon> It's not a bad thing. Just means I need to rewrite about 60 lines of case statement as if statements instead
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
qard has joined #crystal-lang
qard has quit [Client Quit]
snsei has joined #crystal-lang
duane has quit [Ping timeout: 276 seconds]
snsei has quit [Ping timeout: 265 seconds]
alex`` has quit [Ping timeout: 260 seconds]
radagast_04 has joined #crystal-lang
radagast_04 has quit [Ping timeout: 268 seconds]
radagast_04 has joined #crystal-lang
<FromGitter> <bew> Oh ok I see what you mean, could you give an example to see if there's no other ways to do this?
<FromGitter> <CodeTrooperMC> So I downloaded a ZIP of source code but everything is in .cr files... no C source code anywhere...
<FromGitter> <bew> hmm yes, the crystal compiler is written in Crystal :)
<FromGitter> <CodeTrooperMC> That's very confusing........ how is that even possible?
<FromGitter> <bew> ahahah, well at the beginning the compiler was written in Ruby, but at some point, the Ruby compiler compiled a Crystal compiler, and that compiled compiler was able to re-compile itself
<FromGitter> <bew> the switch is explained here: https://crystal-lang.org/2013/11/14/good-bye-ruby-thursday.html
faustinoaq has joined #crystal-lang
faustinoaq has quit [Client Quit]
faustinoaq has joined #crystal-lang
faustinoaq has quit [Quit: IRC client terminated!]
faustinoaq has joined #crystal-lang
faustinoaq has quit [Ping timeout: 248 seconds]
sz0 has joined #crystal-lang
faustinoaq has joined #crystal-lang
faustinoaq has quit [Changing host]
faustinoaq has joined #crystal-lang
dannyAAM has joined #crystal-lang
DTZUZO has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
faustinoaq has quit [Quit: IRC client terminated!]
alex`` has joined #crystal-lang
faustinoaq has joined #crystal-lang
faustinoaq has quit [Client Quit]
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> what's the best way to recursivly go over each key in a json ?
<FromGitter> <bararchy> or, Hash for that matter
jradd has quit [Ping timeout: 248 seconds]
return0e has quit [Read error: No route to host]
return0e has joined #crystal-lang
<FromGitter> <sam0x17> @watzon yeah that switch behavior is also a C/C++ thing I believe. A more readable implementation of that might be to simply allow multiple items, comma delimited, as a case argument (maybe this is already a thing though? haven't played with crystal switch statements yet)
<FromGitter> <sam0x17> @watzon btw thanks for trying to fix that bug with mongo.cr -- still getting errors on my end -- left you a comment
DTZUZO has joined #crystal-lang
<FromGitter> <laginha87> @sam0x17 in crystal you can do have multiple items comma delimited in the when clause
<FromGitter> <bew> well, you can do: `case var = 3; when 1, 2, 3 then ...; end` this will enter the `when` if `var` is either 1, 2 or 3
hightower2 has joined #crystal-lang
hightower3 has quit [Ping timeout: 264 seconds]
rohitpaulk has quit [Ping timeout: 256 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
<FromGitter> <aisrael> I wish Crystal had pattern matching (versus just `case` with multiple items, or fall through, etc.)
rohitpaulk has joined #crystal-lang
<FromGitter> <sam0x17> ^ this, but at the same time retain O(1) where it is possible
<FromGitter> <sam0x17> e.g., do all the const matches first, then try the patterns if none matched
DeBot has joined #crystal-lang
<FromGitter> <aisrael> +1
<FromGitter> <sam0x17> I've been wanting that in *some* programming language for like 10 years lol
<FromGitter> <sdogruyol> @sam0x17 it sounds a bit complicated :P
<FromGitter> <sam0x17> I don't really know how the grammar works but I would imagine as long as it is easy to differentiate const expressions from dynamic expressions it should be easy as pie
<FromGitter> <sam0x17> phase 1: do O(1) lookup for all the const expressions, if no matches enter phase 2: for each dynamic expression, try it out, if it matches, return
<FromGitter> <sdogruyol> I still prefer having a simpler way that just works instead of having multiple phases
<FromGitter> <sam0x17> syntactically it would just work
<FromGitter> <sdogruyol> can't visualize it for now :P
<FromGitter> <sam0x17> the user would just mix in const things and non const things willy nilly -- compiler would parse through that and divide execution into the two phases
<FromGitter> <sam0x17> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5a843a0fce68c3bc7486105e]
<FromGitter> <sam0x17> etc..
<FromGitter> <sam0x17> statically it's easy to tell whether something is phase 1 or phase 2
<FromGitter> <sam0x17> the compiler probably already does that in fact in that it should throw an error when something isn't a const expression with the current implementation
<FromGitter> <sam0x17> the one caveat would be that the const expressions always have precedence, so if one of the non const expressions returns something that is already one of the const options, the non-const block will not execute
<FromGitter> <sam0x17> but that's perfectly reasonable
<FromGitter> <sam0x17> another way of looking at it is do all the const stuff with the O(1) optimization, and then fall back to else if execution style for the rest
<FromGitter> <sam0x17> notice how I mix const and non expressions in terms of ordering -- there are no ordering constraints on the user because the compiler already has enough information
<FromGitter> <sam0x17> if people like this maybe I'll put in a feature request
dragonkh has quit [Ping timeout: 256 seconds]
<FromGitter> <sdogruyol> @sam0x17 please do so, it'll be healthier to have a broader discussion with more
LastWhisper____ has joined #crystal-lang
jradd has joined #crystal-lang
alex`` has quit [Ping timeout: 252 seconds]
duane has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 256 seconds]
<FromGitter> <alexanderadam> I try to forward a captured block as described in the documentation (https://crystal-lang.org/docs/syntax_and_semantics/block_forwarding.html). ⏎ But I have obviously an error in my implementation. ⏎ The block looks has this type `PlaybackBlockType = (::Request, ::Response) -> Nil`, is stored in a configuration and when try it to pass it to a method that *should* accept this block as an argument I get
<FromGitter> ... the following error message: ⏎ ⏎ ``` def on_playback(&@playback_block : PlaybackBlockType) ⏎ end``` ... [https://gitter.im/crystal-lang/crystal?at=5a8451e8ce68c3bc7486b2c0]
<jhass> Basically the type you try to pass is PlaybackBlockType|Nil while the method expects PlaybackBlockType. If you're sure it can't be nil try calling .not_nil!, but it would be better to try to get rid of the nilable in whatever configuration is or at least hide the not_nil! there with a getter! macro
<FromGitter> <alexanderadam> Ah, I see! Now I understand. ⏎ I missed the ` | Nil` of the error message somehow :S ⏎ Awesome. Thank you @jhass!
<jhass> yw, glad it helped
rohitpaulk has joined #crystal-lang
<FromGitter> <alexanderadam> Ah, and is there anything like `remove_instance_variable` in crystal?
<jhass> I would be surprised
<jhass> why?
<FromGitter> <alexanderadam> it's not too bad. I mean I can nil it but I thought maybe it's there and I just can't find it.
<jhass> well crystal generates a memory layout at compile time for your type
<jhass> so you for sure can't change that layout at runtime
rohitpaulk has quit [Remote host closed the connection]
<watzon> @sam0x17 I replied to your comment. I do have the latest version of crystal, but my mongo version is a bit newer. All of the specs are passing for me.
<watzon> aisrael: ++ for pattern matching. Something on the level of Rust or Elixir would be amazing.
<FromGitter> <aisrael> @watzon Exactly what I was thinking of
<watzon> It would be possible to make it happen with a macro if Crystal's macro implementation was more robust, but as it is you can't do too much with them besides some basic code generation
<watzon> I would love to have macros like Nim has
<FromGitter> <aisrael> Why do I get the feeling that Crystal early adopters are either a) Ruby-ists looking for compiled, performant, and type-safe, or b) programming language junkies?
<FromGitter> <xfbs> Because when you are in the Ruby-sphere, you will hear about crystal from your fellow rubyists, when you are a programming language junkie you will hear it from your gang (or from your fellow lobste.rs (https://lobste.rs/) in my case).
<oprypin> aisrael, because that's like the only 2 types of people, except for the 3rd type that goes for whatever is popular
<FromGitter> <xfbs> I think it's just that. A, say, VisualBasic programmer who doesn't happen to have an interest in programming languages just wouldn't ever hear about Crystal
<FromGitter> <CodeTrooperMC> So someone told me awhile ago that Crystal compiles itself now. Does that mean porting to Windows is gonna be extra hard or require a rewrite?
rohitpaulk has joined #crystal-lang
jokke1 has quit [Ping timeout: 256 seconds]
jokke1 has joined #crystal-lang
jokke1 has quit [Client Quit]
<FromGitter> <xfbs> I don't know anything about crystal internals but I think that the fact that it is self-hosting (compiles itself) just means that if you want to get it running on Windows, you need to cross-compile (meaning you will compile the Windows executable on linux/macos)
<FromGitter> <CodeTrooperMC> Oh, okay.
faustinoaq has joined #crystal-lang
<jhass> and once you have obtained a compiler via cross compilation you can use it to compile it again on windows
<FromGitter> <aisrael> From what I’ve heard, it’s not the language/compiler itself that’s the problem—it’s the stdlib, specifically around some file/IO
<FromGitter> <robacarp> I think the big problems for getting crystal to run on windows are interfacing with the system. Files, sockets, etc.
<FromGitter> <j8r> exactly, windows isn't another UN*X OS
<FromGitter> <CodeTrooperMC> Lol, I know.
<FromGitter> <xfbs> That doesn't mean that you can't run crystal under windows right now tho
<FromGitter> <j8r> but maybe with wsl, a bit
<FromGitter> <CodeTrooperMC> I'm just really horrible at using linux-ish stuff as a programming OS.
<FromGitter> <CodeTrooperMC> To do programming stuff.
<FromGitter> <xfbs> Why is that?
<FromGitter> <j8r> that's exactly the opposite of why I'm on on unixes O.o
<wmoxam> ruby/lang junkies at this point makes a lot of sense
<wmoxam> Crystal doesn't have a killer feature/app/use case yet
<FromGitter> <CodeTrooperMC> Maybe I have to learn it or something. But I'm used to stuff like Visual Studio that isn't possible on linux. And all the other windows stuff that doesn't run on linux.
<robacarp> CodeTrooperMC are you saying you're used to an IDE?
<FromGitter> <CodeTrooperMC> No I'm used to VS. And other programs (not IDEs) that don't run on linux.
<FromGitter> <xfbs> What do you use apart from VS?
<watzon> Is is possible to pass a class method as an argument to another method? Basically turning it into a proc.
<FromGitter> <CodeTrooperMC> I did some eclipse, and some codeblocks. ⏎ But I think the real reason is cause I don''t know how to do anything in the terminal. Like install a program.
<robacarp> Getting used to a different software stack isn't quick, but I've found that most of the tools are pretty similar. I think @faustinoaq uses VSCode on linux
<robacarp> oh, yeah, thats a big difference between windows life and linux life
<FromGitter> <xfbs> @CodeTrooperMC do you need some help on how to get set up?
<faustinoaq> Hi :)
<faustinoaq> We're trying to implement a LSP for crystal, see: https://github.com/crystal-lang-tools/scry
<FromGitter> <CodeTrooperMC> Well I already have Ubuntu set up as dual boot. Ive always wanted to learn linux stuff.
<FromGitter> <j8r> @watzon like `{ |log_type, title, msg| Class.log log_type, title, msg }` ? yes, I recently use one to print to stdout
<robacarp> @codetroopermc the learning curve can be a bit steep, but it's rewarding when it clicks. I think you're free to ask questions here
<faustinoaq> Also, @kingsleyh made a nice crystal plugin for intellij idea, https://github.com/crystal-lang-tools/intellij-crystal-lang (just syntax for now)
<robacarp> or you can PM me on gitter
<FromGitter> <CodeTrooperMC> Okay. What is the best linux OS? Or is Ubuntu fine?
<FromGitter> <CodeTrooperMC> Btw what is this bridge bot?
* watzon sent a long message: watzon_2018-02-14_16:38:28.txt <https://matrix.org/_matrix/media/v1/download/matrix.org/sfwziIrzjUOuUMbVyARnnNni>
<robacarp> for starting out, it doesn't matter much. Ubuntu is fine.
<watzon> Or something similar. Really I'd rather just be able to accept the class constant as the argument
<FromGitter> <xfbs> @CodeTrooperMC Ubuntu is just fine. And the bridge bot connects the IRC channel to this gitter
<robacarp> IRC is a chat protocol. This gitter chat is mirrored into an IRC chat room, and Bridge Bot relays messages back and forth
<FromGitter> <robacarp> the other side of the bridge looks like this
* watzon sent a long message: watzon_2018-02-14_16:40:27.txt <https://matrix.org/_matrix/media/v1/download/matrix.org/RWzpsQHuUgSxnfNJbahaSVzz>
<FromGitter> <straight-shoota> @CodeTrooperMC You might want to start using linux/command line in a VM or using Windows Subsystem for Linux instead of dual boot. From my experience, dual boot doesn't make much sense, you'll end up using one main operating system. Having two is not productive.
<FromGitter> <robacarp> There’s truth to that
<FromGitter> <j8r> yeah agree, WSL is a good start!
<FromGitter> <j8r> @watzon you are working on something with matrig.org?
<FromGitter> <robacarp> WSL is a bit of a brain warp looking at the filesystem though
<FromGitter> <CodeTrooperMC> Okay, thanks for the advice guys!
<watzon> Basically I guess I want to be able to at least do something like this https://stackoverflow.com/a/34571917/974936
<watzon> @jr8 no I'm not, what is that? The link failed to resolve.
<watzon> Basically what I'm trying to do is create a middleware handler that allows you to do `.use` with a class. The classes would need to inherit from the abstract `Middleware` class which has an abstract method `handle` defined on it. That handle method then needs to be pushed to an array of middleware.
<watzon> I probably just need to rethink the solution
alex`` has joined #crystal-lang
<watzon> I just want this to not happen when I try to pass a class as an argument `no overload matches 'Tourmaline::Bot::Client#use' with type MyMiddleware:Class`
<FromGitter> <sdogruyol> make it a generic?
<FromGitter> <sdogruyol> or make it accept a generic type
* watzon sent a long message: watzon_2018-02-14_16:56:22.txt <https://matrix.org/_matrix/media/v1/download/matrix.org/rcCCdSwFspWHFTDRFzYvhWUq>
<watzon> The only thing I've been able to get to work so far is changing `Middleware` to `Object`
<FromGitter> <robacarp> Watson: half of your messages are getting replaced by `watzon sent a long message: watzon_2018-02-14_16:56:22.txt https://matrix.org/_matrix/media/v1/download/matrix.org/rcCCdSwFspWHFTDRFzYvhWUq`
<watzon> Lol that's stupid
<FromGitter> <bew> watzon: what do you mean by "uninitialized class"
<FromGitter> <bew> ?
<FromGitter> <robacarp> @j8r was trying to ask why
<FromGitter> <robacarp> I think he meant matrix.org , not matrig.org
<watzon> I mean passing in the class constant instead of an instance of the class
<watzon> And the why, I'm trying to create a middleware handler somewhat similar to rack I guess
<watzon> I get the issue now. I'm using Riot for IRC
<FromGitter> <bew> Use `Middleware.class` for the time restriction of the method?
<FromGitter> <bew> Type*
<FromGitter> <sdogruyol> @watzon just like @bew said
<watzon> Yeah I may have to do that
jradd has quit [Ping timeout: 256 seconds]
alex`` has quit [Quit: WeeChat 2.0.1]
jradd has joined #crystal-lang
jradd has quit [Ping timeout: 256 seconds]
rohitpaulk has quit [Ping timeout: 268 seconds]
jradd has joined #crystal-lang
duane has quit [Ping timeout: 256 seconds]
rohitpaulk has joined #crystal-lang
devil_tux has joined #crystal-lang
<devil_tux> howdy? how can I use regex in Process.run since it messes with quotes
<devil_tux> for some reason grep works in shell (terminal) but not when I call it through the Process component
<FromGitter> <bew> Are you passing the arguments separately?
<FromGitter> <bew> If you do you don't need quotes (unless you have quotes IN the regex)
<devil_tux> FromGitter: no, all through a single cmd
<FromGitter> devil_tux, I'm a bot, *bleep, bloop*. I relay messages between here and https://gitter.im/crystal-lang/crystal
<devil_tux> grep -R '\b[a-zA-Z0-9.-]+@\b' text.raw
<devil_tux> this is regex
alex`` has joined #crystal-lang
alex`` is now known as alexherbo2
alexherbo2 is now known as alex``
<watzon> We need an interpreted version of Crystal for scripting. CrystalScript or something.
<FromGitter> <sdogruyol> that'd be interesting
<FromGitter> <imonmyown> it'd be a pain to implement
<watzon> It would be nice to have. I am planning on writing something like Ruby's God or Eye in Crystal, but I'd love to be able to make the configuration in Crystal itself
<watzon> Can you call the Crystal compiler from Crystal?
DTZUZO has quit [Ping timeout: 255 seconds]
<watzon> I could just have scripts written in Crystal and have the process manager compile and then execute the script
<FromGitter> <sdogruyol> yes you can
<watzon> How would I go about doing that?
<FromGitter> <bararchy> wouldn't using JSON\YAMAL be easier ?
<FromGitter> <sdogruyol> this might help you @watzon https://github.com/crystal-lang/crystal/wiki/Compiler-internals
<watzon> Sure it would, its just not as robust
<watzon> Lol
<watzon> icr(0.24.1) > require "compiler/crystal"
<watzon> Error in .icr_eFRRYxP7bip8uLuwO6hdig.cr:2: Please use `make crystal` to build the compiler, or set the i_know_what_im_doing flag if you know what you're doing
<devil_tux> https://play.crystal-lang.org/#/r/3l4t can someone check this or help me pass arguments properly
<watzon> So there's no way to have a compiled crystal program compile another script without having the compiler installed it looks like
<watzon> I guess that would require the program to have the full crystal compiler built in though anyway
TakeYourFreedom has joined #crystal-lang
<watzon> devil_tux: try something like this https://play.crystal-lang.org/#/r/3l4v
<watzon> You can use backticks to execute shell commands. The output is automatically converted to a string
<devil_tux> watzon: oh yes .. what I was thinking, didn't even try that
<watzon> I think for it to work with Process you may have to pass it the full path to grep? Or maybe it's just the way you were piping the output. Idk
<devil_tux> watzon: still can't grep anything .. it's like grep returns to different std
duane has joined #crystal-lang
Ven`` has joined #crystal-lang
<devil_tux> watzon: tested with full path already
<watzon> You say that grep command works fine normally?
<watzon> Grep works fine for me in crystal
<devil_tux> grep "\b@\b" text.raw >> email@me.grep
<devil_tux> through crystal it just outputs ""
<devil_tux> watzon: some basic operands works but regex does not
<watzon> Have you tried escaping the backslashes?
Ven` has joined #crystal-lang
<watzon> `grep "\\b@\\b" text.raw`
Ven` has quit [Read error: Connection reset by peer]
<devil_tux> watzon: that works, im funny ...
Ven` has joined #crystal-lang
<devil_tux> still didn't really make sense since printing it yielded correct command
Ven`` has quit [Ping timeout: 268 seconds]
<watzon> Yeah I really don't know what the case was with your other attempt
<watzon> to my mind the b's should have been escaped
sz0 has quit [Quit: Connection closed for inactivity]
<devil_tux> watzon: appreciated your help
<watzon> No problem
rohitpaulk has quit [Ping timeout: 256 seconds]
Ven` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven`` has joined #crystal-lang
<oprypin> welp now i am sold on "no recursive aliases"
Poeticode has quit [Ping timeout: 265 seconds]
return0e has quit [Remote host closed the connection]
Poeticode has joined #crystal-lang
<watzon> Is it possible to wrap Logger into a module so that I can use it throughout my app without creating multiple instances of the Logger class?
* watzon sent a long message: watzon_2018-02-14_20:11:45.txt <https://matrix.org/_matrix/media/v1/download/matrix.org/XgeNrJrlifxqZlJZjVmrCwNb>
<watzon> This doesn't work, probably because I want the methods to be static and forward_missing_to is going to make them instance methods
Ven`` has quit [Read error: Connection reset by peer]
Poeticode has quit [Client Quit]
Ven`` has joined #crystal-lang
Poeticode has joined #crystal-lang
Poeticode has quit [Changing host]
Poeticode has joined #crystal-lang
<FromGitter> <straight-shoota> oprypin, yeah it makes sense
TakeYourFreedom has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
Ven`` has quit [Ping timeout: 265 seconds]
Ven`` has joined #crystal-lang
Ven`` has quit [Ping timeout: 240 seconds]
Ven`` has joined #crystal-lang
Ven`` has quit [Ping timeout: 264 seconds]
Ven`` has joined #crystal-lang
Ven`` has quit [Client Quit]
alex`` has quit [Ping timeout: 240 seconds]
<FromGitter> <bew> watzon: just put your `LOGGER` instance in the `Deus` namespace, not in `Deus::Logger`, this xay you can do `Deus::LOGGER.debug ...`
<watzon> Now that you say that it sounds so obvious haha
<FromGitter> <bew> No need for macro stuff generating missing methods, just use the LOGGER instance directly
return0e has joined #crystal-lang
<FromGitter> <bew> :)
faustinoaq has quit [Ping timeout: 248 seconds]
<FromGitter> <bew> watzon: about the `\b` you said you thought it would have been escaped => Why? And if so, how do you put a `\b` (called backspace in 'man ascii') ?
<watzon> Because it was in a string
<FromGitter> <bew> when you use `"\n"` it's not escaped as `"\\n"`
<FromGitter> <bew> if you want that, you can use `%q(\n)`
<FromGitter> <bew> this is the raw string literal, everything in there will be as is, without any understanding on the content like `\` then `n` is a converted to a newline in normal string literal.
rohitpaulk has joined #crystal-lang
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
rohitpaulk has quit [Ping timeout: 264 seconds]
devil_tux has quit [Ping timeout: 265 seconds]
<watzon> So you're saying a double backslash doesn't escape? So `\\n` wouldn't escape the newline?
<FromGitter> <bew> huh no, I'm not saying that
devil_tux has joined #crystal-lang
<FromGitter> <bew> `\n` gives you the char newline, `\\n` gives you 2 chars `\` and `n`
<FromGitter> <bew> https://carc.in/#/r/3l6z
<FromGitter> <bew> https://carc.in/#/r/3l70 watzon
<watzon> What's the difference between `p` and `puts`? Because if you do `puts "foo\nbar"` the newline is inserted as a newline literal and `puts "foo\\nbar"` escapes the literal.
<FromGitter> <bew> `puts` will just print the string with a call to `to_s` on the object(s), `p` will do the same but bye calling `inspect` on the object(s)
<watzon> Ahh I see. `p` and `pp` are the same?
<FromGitter> <bew> almost
<FromGitter> <bew> `pp` will also print before what you gave it, e.g: `pp 1 + 2` will give `1 + 2 # => 3`
<FromGitter> <bew> `pp` is a macro, this is wy it is able to get and print `1 + 2`
<watzon> Ahh I see
<watzon> Ok cool
<FromGitter> <bew> All this is explained in the docs!
<FromGitter> <bew> or API
<watzon> But my point I think is still valid, unless I'm missing something. When a string, not a raw one, is printed `\n` becomes a newline literal and `\\n` becomes an escaped `\n` right?
<watzon> That's why I figured the `\b` might be getting escaped before it got passed to grep.
<FromGitter> <bew> yes but no, to escape `\b` you would have to write `\\b`
<FromGitter> <bew> to have an escaped `\b` as you just said for `\n`
tobyfree has joined #crystal-lang
<tobyfree> is anyone here familiar with file uploads in kemal?
<watzon> Exactly haha. So when his `\b` was passed to grep it got passed as an unescaped literal, but grep expected to receive an escaped one
<watzon> At least that's what my thought process was. It seemed to work.
<tobyfree> i'm getting a missing hash key error when trying to access env.params.files[
greengriminal has joined #crystal-lang
<FromGitter> <bew> ah yes watzon, grep want `\b` as 2 chars, so when writing the string in Crystal, you have to escape it, so that it is sent as 2 chars and not one
<watzon> Are you sure the key you're expecting to be there is actually there?
<FromGitter> <bew> \o/ x)
<watzon> @bew yup, that's the point I was trying to make haha
<watzon> tobyfree: you can check if the key is there first by using `Hash#has_key?`
<FromGitter> <bew> perfect then, long discussion to realize we were saying the same thing ^^
<watzon> Or list all the keys for debugging purposes with `Hash#keys`
<FromGitter> <aisrael> @watzon “ We need an interpreted version of Crystal for scripting. CrystalScript or something.” ⏎ ⏎ Uhm, isn’t that called Ruby? /snark
<watzon> I figured we were haha. It's just hard to communicate these sometimes
<watzon> @aisrael I was waiting for someone to say that
<watzon> Lol
<tobyfree> watzon, no, it doesn't seem like its being parsed by kemal. the file input is named correctly and I have enctype="multipart/form-data", tested in both curl and chrome
<FromGitter> <bew> yeah and I'm not a native english speaker, so I prefer to over-explain to make sure the message pass
<watzon> @bew that seems like the safe option
<FromGitter> <bew> but sometimes I don't understand what other are saying (or missing the context) so we have this kind of discussion
<tobyfree> ah, it might be in env.params.body and not env.params.files
greengriminal has quit [Quit: Leaving]
duane has quit [Ping timeout: 255 seconds]
<tobyfree> ah nevermind, I had a type in my enctype attribute, not sure why it was failing with curl though
<tobyfree> typo*
devil_tux has quit [Quit: leaving]