pawnbox has quit [Remote host closed the connection]
<BlaXpirit>
jhass, check out my suggestion for the bot. Instead of wrapping code in a macro, parse the code right away and wrap the last expression properly. Also the code is expanded from one line to be more readable (though it's not always perfect) https://gist.github.com/8b1c593b3782f10d6a71
dsounded has joined #crystal-lang
tomchapin has joined #crystal-lang
<BlaXpirit>
I'd make a pull request right away but there are multiple problems to be considered. this makes the transforming program itself require crystal, and if syntax changes the old versions of crystal wouldn't match it. and not sure if it's best put into carc.in or debot
<dsounded>
it shows: crystal 0.14.2-1 amd64 The full stack of crystal
<dsounded>
Also it shows this: Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
<BlaXpirit>
>> case Bool.class; when Bool; p ":)"; end
dome22xl has quit [Read error: Connection reset by peer]
dtakahas has joined #crystal-lang
emancu has quit []
<dtakahas>
Hi all - I'm writing my first crystal script here and I'm running into some kind of DNS error (?). Maybe I'm missing a lib. Here's the gist if anyone is able to take a look: https://gist.github.com/dtakahas/78f1cbd8cdc7714d9c62
<BlaXpirit>
dtakahas, works here. have u tried without https?
<dtakahas>
trying
<dtakahas>
Huh even without ssl it's still saying 'getaddrinfo: nodename nor servname provided, or not known (Socket::Error)'. Something with my network maybe? Thanks for trying!
<RX14>
dtakahas, what SO?
<RX14>
OS*
<RX14>
can you install dig and try and use it to lookup the same hostname
ragmaanir has joined #crystal-lang
<BlaXpirit>
>> LibC.getaddrinfo("google.com", nil, nil, out result); p result.value.addr.value
mgarciaisaia has left #crystal-lang [#crystal-lang]
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<RX14>
huh
rolha has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
pawnbox has joined #crystal-lang
rolha has joined #crystal-lang
Rinkana has quit [Ping timeout: 250 seconds]
pawnbox has quit [Ping timeout: 246 seconds]
rolha has quit [Remote host closed the connection]
rolha has joined #crystal-lang
tony_ has quit [Ping timeout: 248 seconds]
Philpax has joined #crystal-lang
pawnbox has joined #crystal-lang
dtakahas has quit [Ping timeout: 250 seconds]
pawnbox has quit [Ping timeout: 276 seconds]
dtakahas has joined #crystal-lang
<luislavena>
dtakahas: behind a proxy?
trapped has quit [Read error: Connection reset by peer]
<luislavena>
dtakahas: actually, the problem is "https://www.google.com", HTTP::Client.new is expecting host, port, ssl option, not an URI, port
<RX14>
luislavena, i think he said he tried it without the htpps
<luislavena>
dtakahas: if you remove the protocol from the host, it should work: http://crystal-lang.org/api/HTTP/Client.html#new%28host%2Cport%3D%3Cspanclass%3D%22n%22%3Enil%3C%2Fspan%3E%2Cssl%3D%3Cspanclass%3D%22n%22%3Efalse%3C%2Fspan%3E%2C%26block%29-class-method
<luislavena>
RX14: I tried his code and it failed the same way, looked at the docs, removed the https:// part of the host, and it worked.
<RX14>
huh
<BlaXpirit>
https://carc.in/#/r/viq so I'm using macro included as a hack to get access to a TypeNode. is there any way to do it without the hack? commented out code doesn't work
<BlaXpirit>
no but seriously.. I'm going crazy here
<BlaXpirit>
is macro included really the only way to simulate a macro argument that is a type?
<RX14>
well
<RX14>
it might happen before the phase where types are determined like that
<ragmaanir>
"If the constant denotes a type, you get back a TypeNode"
<ragmaanir>
not tested it
<BlaXpirit>
ragmaanir, ok but see my code
<BlaXpirit>
I want to reuse the macro for different types (known at compile time), and this requires you to have an exact type hardcoded in a macro
<BlaXpirit>
i mean "include Constants(E)" sounds even cooler than a macro but mhm
<ragmaanir>
hm, i have to think this through .. macros are a little weired IMO
<BlaXpirit>
they sure are
<ragmaanir>
i am also thinking about how to redesign macros, because at the moment they are more like code templates, so when you write macros with logic, it gets really ugly
<BlaXpirit>
well sure... best would be to just interpret crystal code at compile time
<BlaXpirit>
"just"
<ragmaanir>
yeah
<BlaXpirit>
but for now i got an idea brewing
<ragmaanir>
thats kinda what i want to propose, but im pretty sure there are some caveats, especially with typing etc
pawnbox has joined #crystal-lang
<BlaXpirit>
(idea totally stolen from Nim)
<BlaXpirit>
have 2 kinds of macro arguments: expression (which is currently the only one) and a constant
<ragmaanir>
btw you can pass code via the run call from a macro to a crystal file which runs arbitraty crystal code, but then you loose the AST information :-/
<ragmaanir>
yeah, i also though of 2 types of parameters for macros. you probably even could put type restrictions on the expression parameters, so e.g. you macro is only applicable to tuple literals or so.
<ragmaanir>
what it does is: it converts the macro input parameters to strings and the block to a method. then it passes these to the run-call. the eval macro then executes the passed method on the passed parametes. the output that is generated via puts is then the output of the macro.
<ragmaanir>
so basically in the block you can write what to do with the macro parameters, and you can write regular crystal code.
<ragmaanir>
sadly all the AST information gets lost.
<ragmaanir>
IMO: macros should be regular crystal code, and when you want to generate stuff you can either generate a string which the macro returns, or you can build AST nodes, which are returned.
<BlaXpirit>
flattening tuple? now that's something I can get behind
<BlaXpirit>
ragmaanir, are you coming from Nim?
<ragmaanir>
no, from ruby and scala.
<BlaXpirit>
the thing is, Nim's macros are what we're describing here
<ragmaanir>
oh, k. then i gonna have a look at those, thanks.
<BlaXpirit>
but don't get too excited, cuz I left Nim for Crystal
<ragmaanir>
^^
<ragmaanir>
i only wanna steal the macros ;-)
zodiak has joined #crystal-lang
<ragmaanir>
i left ruby and scala for crystal
<ragmaanir>
and did not look deeply into rust, d and go, because crytal is all i need.