jhass changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.1 | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <Daniel-Worrall> Windows support would be very handy for me since I primarily develop from Windows (gamer luls) and I wish to distribute client facing apps to Windows users
<hightower3> Certainly, Windows support would be amazing. Not for me personally, but seeing that PHP and Python work on Windows... :)
DTZUZU is now known as toxix
<FromGitter> <ImAHopelessDev_gitlab> @Daniel-Worrall why not just use electron? you can distribute to every platform
deavmi has quit [Ping timeout: 240 seconds]
<FromGitter> <Daniel-Worrall> Because I like crystal?
<FromGitter> <ImAHopelessDev_gitlab> :D
<FromGitter> <ImAHopelessDev_gitlab> i forgot /s srry
duane has quit [Ping timeout: 264 seconds]
duane has joined #crystal-lang
deavmi has joined #crystal-lang
<FromGitter> <3n-k1> i'm getting `Error: undefined macro method 'Call#inspect'` on this code: `temp = {% x.inspect %}` ⏎ but the api docs for macro say it inherits the inspect method
<FromGitter> <3n-k1> am i doing something wrong?
<FromGitter> <Blacksmoke16> Does it?
<FromGitter> <3n-k1> "instance methods inherited from object"
<FromGitter> <Blacksmoke16> Mm yea I dunno if that's totally accurate
<FromGitter> <3n-k1> oh i bet i want stringify
<FromGitter> <Blacksmoke16> Just do pp x
<FromGitter> <3n-k1> i don't wanna print it tho
<FromGitter> <Blacksmoke16> Oh ok
<FromGitter> <3n-k1> sounds like the issue is the docs for macro are for a fictional package, and so the documenation generator just assumes it must inherit from object even though it doesn't
<FromGitter> <Blacksmoke16> That sounds about right
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 260 seconds]
<FromGitter> <3n-k1> is there a way to restrict the type of a macro argument?
<FromGitter> <Blacksmoke16> no but you can do like `{% raise "Value should be a String" unless value.is_a? StringLiteral %}`
<FromGitter> <3n-k1> coolio ty
<FromGitter> <3n-k1> i love that you're basically just my crystal mentor right now haha
<FromGitter> <Blacksmoke16> things get slower in US tz :p
<FromGitter> <3n-k1> i don't know what it says about me that i'm currently in the us
<FromGitter> <3n-k1> also, seems that line doesn't work for an enum
<FromGitter> <Blacksmoke16> got some example code?
<FromGitter> <3n-k1> ```code paste, see link``` ⏎ ⏎ calling it without specifying status raises the error [https://gitter.im/crystal-lang/crystal?at=5fb5e52d06fa0513ddc04025]
<FromGitter> <Blacksmoke16> :thinking:
<FromGitter> <Blacksmoke16> what happens if you add like `{% pp value, typeof(value) %}`
<FromGitter> <3n-k1> can't execute typeOf in a macro
<FromGitter> <Blacksmoke16> er `value.class`
<FromGitter> <3n-k1> `HTTP::Status::BAD_REQUEST`
<FromGitter> <3n-k1> that and nothing else
<FromGitter> <3n-k1> oh `Error: undefined macro method 'Path#class'`
<FromGitter> <3n-k1> i'm gonna have to manually split this and check it, aren't io
<FromGitter> <Blacksmoke16> alright yea it actually makes sense
<FromGitter> <Blacksmoke16> `HTTP::Status::BAD_REQUEST` is technically a `NumberLiteral`
<FromGitter> <Blacksmoke16> does this have to be a macro tho?
<FromGitter> <3n-k1> yeah
<FromGitter> <Blacksmoke16> why?
<FromGitter> <3n-k1> can i throw an exception in an athena route to return an HTTP 400?
<FromGitter> <3n-k1> otherwise i need to return directly
<FromGitter> <Blacksmoke16> yes `raise ART::Exceptions::BadRequest.new "err"`
<FromGitter> <3n-k1> coolio, that works
<FromGitter> <3n-k1> ty
<FromGitter> <Blacksmoke16> it'll return JSON if thats ok?
<FromGitter> <Blacksmoke16> is a way to customize the response tho
<FromGitter> <3n-k1> there we go, this is sufficiently cursed and works ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5fb5e75a8d286f2076ba8f17]
<FromGitter> <Blacksmoke16> :thinking:
chachasmooth has quit [Ping timeout: 264 seconds]
<FromGitter> <3n-k1> it compiles and doesn't crash, all that matters xd
<FromGitter> <Blacksmoke16> im still skeptical you need a macro tho
<FromGitter> <3n-k1> need?
<FromGitter> <3n-k1> no
<FromGitter> <3n-k1> but convenience
<FromGitter> <Blacksmoke16> i meant wouldnt a method do the same thing?
<FromGitter> <3n-k1> so now i can just do `assert !username.empty?`
<FromGitter> <3n-k1> ```code paste, see link``` ⏎ ⏎ so the macro returns from the view method directly [https://gitter.im/crystal-lang/crystal?at=5fb5e7ae2a35440715343198]
chachasmooth has joined #crystal-lang
<FromGitter> <3n-k1> it saves typing, and i am lazy
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5fb5e7e97cac87158fb5e2cd]
<FromGitter> <3n-k1> but that returns json
<FromGitter> <Blacksmoke16> could use that to customize it
<FromGitter> <3n-k1> let me feel smart for two seconds :p
<FromGitter> <3n-k1> (kidding btw)
<FromGitter> <Blacksmoke16> 🙈
avane has quit [Quit: ZNC - https://znc.in]
avane has joined #crystal-lang
deavmi has quit [Ping timeout: 260 seconds]
deavmi has joined #crystal-lang
duane has quit [Ping timeout: 260 seconds]
<FromGitter> <mattrberry> Currently seeing this error: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Any idea why the compiler is complaining? [https://gitter.im/crystal-lang/crystal?at=5fb61a1ebf955735eb8b4ead]
<FromGitter> <mattrberry> Hmm, it doesn't complain if I don't do the ⏎ ⏎ ```@ppu = (@fifo ? FifoPPU : ScanlinePPU).new self``` [https://gitter.im/crystal-lang/crystal?at=5fb61a58f2fd4f60fc81c59a]
<FromGitter> <mattrberry> Is that meant to error out?
<FromGitter> <mattrberry> This works fine ⏎ ⏎ ```@ppu = @fifo ? FifoPPU.new self : ScanlinePPU.new self``` [https://gitter.im/crystal-lang/crystal?at=5fb61aa006fa0513ddc0b17f]
<FromGitter> <naqvis> are you invoking parent constructor in child constructor?
melthelesbian has quit [Ping timeout: 264 seconds]
melthelesbian has joined #crystal-lang
sagax has quit [Ping timeout: 260 seconds]
<FromGitter> <asterite> I think it errors because palette is initialized inside a macro if, and the compiler can't see it
<FromGitter> <asterite> ah, no, that's not it
_whitelogger has joined #crystal-lang
Human_G33k has quit [Ping timeout: 272 seconds]
HumanG33k has joined #crystal-lang
duane has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
duane has quit [Ping timeout: 272 seconds]
duane has joined #crystal-lang
HumanG33k has quit [Quit: Leaving]
sagax has joined #crystal-lang
duane has quit [Ping timeout: 260 seconds]
ua_ has quit [Read error: Connection reset by peer]
ua has joined #crystal-lang
duane has joined #crystal-lang
HumanG33k has joined #crystal-lang
ua has quit [Excess Flood]
ua has joined #crystal-lang
ua has quit [Quit: Leaving]
toxix has quit [Ping timeout: 256 seconds]
ua has joined #crystal-lang
toxix has joined #crystal-lang
<FromGitter> <franciscoadasme> hey everyone, to my understanding this should work, right? but it prints an empty array. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5fb6b7d074152347c244953d]
<FromGitter> <Blacksmoke16> `instance_vars` only works in the context of a method
hightower3 has quit [Ping timeout: 240 seconds]
<FromGitter> <franciscoadasme> oh, I didn't know that... is it mentioned somewhere in the guides?
<FromGitter> <Blacksmoke16> not that i can remember
hightower4 has joined #crystal-lang
Nekka has quit [Ping timeout: 256 seconds]
Nekka has joined #crystal-lang
<FromGitter> <anthonyshull> is it not allowed to have a property that ends in ? `getter residential? : Bool`
<FromGitter> <Blacksmoke16> correct, do `getter? residential : Bool`
<FromGitter> <anthonyshull> ah
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Object.html#getter?(*names,&block)-macro
<FromGitter> <anthonyshull> haha, is there somewhere i can read all of this stuff? like in more narrative form?
<FromGitter> <Blacksmoke16> not sure if this is in the book, but id read thru the api docs
<FromGitter> <Blacksmoke16> at least for the more common types
<FromGitter> <anthonyshull> i got teh programming crystal book, but don't remember it going over these things
<FromGitter> <Blacksmoke16> https://crystal-lang.org/reference/ this book i mean
<FromGitter> <anthonyshull> 👍
<FromGitter> <Blacksmoke16> thats also a good resource, but idt its in there either
<straight-shoota> `property` and `getter` are briefly mentioned in the reference but its focus is on describing the language proper.
<straight-shoota> These macros are part of stdlib and documented at https://crystal-lang.org/api/master/Object.html
<straight-shoota> We're missing a proper guide to stdlib unfortunately
hightower4 has quit [Ping timeout: 256 seconds]
toxix is now known as DTZUZU
Nekka has quit [Ping timeout: 246 seconds]
<raz> hmm, a minor thing that i keep bumping into: ''. do we really need these single-purpose, c-style single quotes?
Nekka has joined #crystal-lang
<FromGitter> <j8r> for chars?
<raz> yea
<raz> like how often do people need a literal char? i use it like once a month maybe. but bump into accidental single-quoted strings all the time when switching between ruby and crystal
<FromGitter> <j8r> no, you can use `97.unsafe_chr` if you prefer haha
<raz> well yea, i'd be happy to do that if i can then use single quotes for strings :p
<FromGitter> <j8r> always use double everywhere
<raz> on my keyboard a double quote takes twice the work!
<FromGitter> <j8r> that's a convention
<FromGitter> <j8r> maybe, there will always have some guy with an exotic keyboard to have a similar issue
<raz> i'm not sure i'd call US-layout exotic :p
<FromGitter> <j8r> trlol :3
<FromGitter> <j8r> that's not that problematic
<FromGitter> <j8r> then never use caps
<straight-shoota> raz, yeah I've run into that as well
<straight-shoota> But nowadays it doesn't even make a difference in Ruby, so you could just get used to double everywhere
<FromGitter> <j8r> Use Azerty - problem solved, and 100 more created
<FromGitter> <j8r> haha
<raz> yup, but ruby convention is the exact opposite
<straight-shoota> Almost every language uses double quotes
<FromGitter> <j8r> what would you use for char literals then?
<raz> well, the two ones i use the most (ruby and JS) don't
<raz> 97.chr
<FromGitter> <Blacksmoke16> PHP doesnt, `'` is still for non interpolation, but both work :shrug:
<raz> i mean really how often do you need that?
<straight-shoota> ruby and JS also use double quotes
<straight-shoota> but you can use singles as well
<FromGitter> <3n-k1> i'm amazed y'all are talking about keyboard layouts and nobody mentioned dvorak lol
<raz> yup, most people i know just default to singles cause it's easier to type, slightly cleaner on the eyes
<straight-shoota> great to have you help out =)
<FromGitter> <j8r> or Bepo @3n-k1
<FromGitter> <j8r> dvorak is quite good
<raz> where is the single quote on dvorak?
* raz imagines it to involve a foot pedal
<FromGitter> <j8r> designing a language around the US QWERTY sounds to be a bad idea
<straight-shoota> a foot pedal could be the solution to your problem
<FromGitter> <3n-k1> i'm sure it involves playing beethoven on a piano, and dvorak proponents will say it makes sense
<straight-shoota> just configure it to double quote character
<straight-shoota> and you could use a font that displays double quotes as singles
<FromGitter> <3n-k1> i have a friend who types like 30 wpm on a normal us-layout because he's so used to dvorak lol
<FromGitter> <j8r> or speech to text, when you say "quotes" quotes will be written :)
<FromGitter> <Blacksmoke16> im sure you could switch the key, i.e. shift + ' == "
<raz> great idea with the font. so i don't even see when i got it wrong until the compiler barfs at me :p
<FromGitter> <Blacksmoke16> er == `'`
<raz> but i might actually try to map ' to " in my editor hmm
<straight-shoota> well the font would obviously show something else for single quotes
<straight-shoota> maybe a little kitten
<FromGitter> <j8r> raz: map " to ' and ' to " ?
<straight-shoota> to bad you won't see any of them
<raz> j8r: no, only ' to ". only for crystal files since i pretty much never need ' there
<FromGitter> <j8r> maybe, replacing double ' to " with a `sed` command?
<raz> and then i'll get a midi foot pedal for when i actually need a literal char
<raz> well, sed is too rough. that would surely break that one file in my codebase that actually has a char ¯\_(ツ)_/¯
<FromGitter> <j8r> noo
<FromGitter> <j8r> because double simple quote one after another
<FromGitter> <j8r> this is very rare
<FromGitter> <j8r> `sed -i "s/''/\"/g"`
<FromGitter> <Simerax> Im currently writing a lot of spec code with the following pattern: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5fb7001f2a3544071536ff4c]
<straight-shoota> you know what would even be much better than a foot pedal (even if it was an organ pedal and you could play beethoven on it)?
<straight-shoota> using gesture recognition =)
<FromGitter> <Blacksmoke16> @Simerax did you try like
<FromGitter> <Blacksmoke16> ```var = var.should be_a TypeX ⏎ var.flag.should be_true``` [https://gitter.im/crystal-lang/crystal?at=5fb7004ec10273610a172c12]
<raz> straight-shoota: ha, my laptop has a touchbar. this could actually finally become useful
<raz> just a full-width single-quote button
<FromGitter> <Blacksmoke16> i know that works for like `should_not be_nil`, but i dont remember if that case was also supported...
<FromGitter> <Simerax> @Blacksmoke16 Nice that works!
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <Blacksmoke16> or maybe `var.should(be_a(TypeX)).tap &.flag.should(be_true)` :S
<straight-shoota> raz: But honestly, I see the point about char literals not being very useful. Unless you're writing a parser or some data format implementation, you're unlikely to need one.
<straight-shoota> It's too late to change the syntax now.
<FromGitter> <Simerax> i think i'll stick with the first one its clear and easy :P
<straight-shoota> And having double and single do the same thing would be like an alias, so a big NO in Crystal :D
<straight-shoota> Except that there are about a dozen different string literals ¯\_(ツ)_/¯
<raz> yup, that's how i see it, too. there's certain types of code where you need lots of chars (protocol parsers indeed). but i find those very rare.
<straight-shoota> A nice alternative syntax for char literals could be similar to number literals, like `0cA`
<oprypin> what no
<straight-shoota> It's not even more to write and makes it clear that it's something different than a string
<straight-shoota> Just talking crazy ideas, opryping. Not gonna happen
<FromGitter> <3n-k1> are there any libraries for parsing crystal code, kinda like python's `ast`?
<FromGitter> <j8r> @3n-k1 `require "compiler/crystal/syntax"`
<FromGitter> <j8r> then you can use `Crystal::Parser.parse`
<FromGitter> <j8r> not really documented
<FromGitter> <3n-k1> awesome. no docs is fine, but is it a stable interface?
<FromGitter> <3n-k1> or at least, relatively stable
<FromGitter> <Blacksmoke16> i wouldnt rely on it
<FromGitter> <Blacksmoke16> its an internal non public api
<FromGitter> <3n-k1> that's what i was afraid of
<FromGitter> <3n-k1> well, ast-helper has survived a year without any issues, should be fine
<oprypin> 3n-k1, what no it's relatively stable
<straight-shoota> yeah, the compiler's internal API doesn't change that much
<FromGitter> <3n-k1> oh sick, thanks
<straight-shoota> but when it does there won't be deprecation notices or something like that
<FromGitter> <j8r> @3n-k1 what do you want to implement?