faustinoaq has quit [Read error: Connection reset by peer]
<FromGitter>
<lbarasti> Hi folks. I'm struggling with some macro + underscore business. ⏎ Is it legal to define a macro that returns a tuple containing `_`? ⏎ This would be for pattern matching purposes. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5a4c1d69b48e8c3566926c68]
<RX14>
nope
<RX14>
i don't think it is
<RX14>
well you can try it but I doubt it
<FromGitter>
<lbarasti> Thanks, yes, that matches my experience. Do you know of any workaround to produce `_` in that context?
<RX14>
you need to macro the whole case statement
<FromGitter>
<lbarasti> like an `extended_case` kind of thing you mean
<RX14>
not really
<RX14>
you just need a macro that expands to the case statement with the {_, 5} already in it
<FromGitter>
<straight-shoota> I think that's what he was getting at
<FromGitter>
<lbarasti> yep, I think I get what you mean. Sounds good, I'll give that a try, thanks :)
<FromGitter>
<lbarasti> mhmh, thinking about it, I'm afraid even producing an underscore programmatically might totally kill the fun. I'd need to define my macro to accept a `{_, 5}` like expression. Not sure the AST will be happy with that
<oprypin>
lbarasti, you can use https://carc.in to share runnable examples. that's nicer for IRC folks, as well
<FromGitter>
<lbarasti> @FromIRC RX14 I'd like to get to a point where one can write something along the lines of ⏎ ⏎ ```person = Person.new("John", 18) ⏎ case person ⏎ when Person(_, 18) then "success" ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5a4c2154edd223081106216a]
<oprypin>
that's just hopeless
<FromGitter>
<lbarasti> Thanks orpypin, here is the previous working example in carc.in: https://carc.in/#/r/3bw2
<FromGitter>
<lbarasti> > **<oprypin>** that's just hopeless ⏎ Yes, it is with that syntax 😄 ⏎ I'll try with something different - nowhere near as clear
<oprypin>
lbarasti, i think it's a good idea to drop `case` at some point and rely on a chain of conditions if you're gonna fully replace it a anyway
<oprypin>
that way it might be easier to stack
<oprypin>
also consider using `return` in those because a macro can't start with elsif
rohitpaulk has quit [Ping timeout: 240 seconds]
<oprypin>
(macros need to be full valid expressions)
<oprypin>
that's all from me
<RX14>
@lbarasti if you consider what's an AST node in crystal - a macro has to return what can be parsed intoa full AST node
<RX14>
actually, an easier way to think: if you placed just what the macro returned into an empty file, it has to be valid crystal (it can be nonsensical though)
<FromGitter>
<lbarasti> > **<RX14>** actually, an easier way to think: if you placed just what the macro returned into an empty file, it has to be valid crystal (it can be nonsensical though) ⏎ ⏎ That helps, I guess in my case it means `_` can only appear next to a `when` clause
<RX14>
yes
<FromGitter>
<lbarasti> > **<oprypin>** @lbarasti, i think it's a good idea to drop `case` at some point and rely on a chain of conditions if you're gonna fully replace it a anyway ⏎ ⏎ That's a good point, I might have to give up the idea of exploiting `_` though, if I understand the way it gets desugared
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter>
<lbarasti> Thanks a lot to both, hope I can get something out of these suggestions! Cheers
cremes has joined #crystal-lang
<FromGitter>
<straight-shoota> @RX14 an idea on that? ⏎ ⏎ > Now the linker gives this error: ⏎ `gc.lib(misc.obj) : error LNK2019: unresolved external symbol __imp_MessageBoxA referenced in function GC_win32_MessageBoxA ⏎ spec_test.exe : fatal error LNK1120: 1 unresolved externals` [https://gitter.im/crystal-lang/crystal?at=5a4c29ed0163b02810a6205f]
<RX14>
Yes
<RX14>
There's an extra flag you need
<RX14>
To the libgc build
<RX14>
But you might be able to get away with adding user32.lib to the link command
<RX14>
Or maybe it was kernel32.lib
<RX14>
I'm on my phone I'll work it out tomorrow
<RX14>
Its 1am lol
greengriminal has joined #crystal-lang
alexherbo2 has quit [Quit: WeeChat 1.9]
sz0 has quit [Quit: Connection closed for inactivity]
alex``` has joined #crystal-lang
illyohs has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
alex``` has quit [Quit: WeeChat 1.9]
vivus has quit [Quit: Leaving]
<crystal-gh>
[crystal] MakeNowJust opened pull request #5513: Add ASTNode#single_expression and refactor with using it (master...fix/crystal/ast-single-expression) https://git.io/vbjeI
cremes has quit [Quit: cremes]
DTZUZU has joined #crystal-lang
illyohs has quit [Ping timeout: 272 seconds]
greengriminal has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter>
<codenoid> helo. i have crystalphobic friend
<FromGitter>
<vpereira> lvmbdv: from Wikipedia: "In computer science, binary search, also known as half-interval search,[1] logarithmic search,[2] or binary chop,[3]" :P
<lvmbdv>
when i hear "binary search" i think "computers"
<FromGitter>
<vpereira> me too, thats why the class name is Karate :^)
<FromGitter>
<vpereira> those uiaaaaaaaaaaa uhhhhhhhhhhhhhh and the crystal minions chopping an array like crazy
<FromGitter>
<codenoid> hahaha, yes @lvmbdv
ua has quit [Excess Flood]
<lvmbdv>
then their opinion can be automatically discarded codenoid
<FromGitter>
<marin117> can anybody help me with writing from_json method for time::span?
<FromGitter>
<marin117> I have json mappings with span types
<FromGitter>
<marin117> and either I get undefined method 'to_i64' for JSON::PullParser error
<FromGitter>
<marin117> or it won't convert all data from json
rohitpaulk has quit [Read error: Connection reset by peer]
rohitpaulk has joined #crystal-lang
ua has joined #crystal-lang
ua has quit [Remote host closed the connection]
ua has joined #crystal-lang
bew has joined #crystal-lang
<crystal-gh>
[crystal] Wulfklaue opened pull request #5515: Returns the effective, real group and user ID of the current process (master...master) https://git.io/vbjBK
alex`` has joined #crystal-lang
jnyw has quit [Quit: WeeChat 2.0.1]
<FromGitter>
<straight-shoota> @RX14 With user32.lib it works 👍
<RX14>
Nice
<RX14>
There's a cmake option to compile pcre so it doesn't depend on user32
<RX14>
That's what I think is the real solution.
Liothen has quit [Quit: The Dogmatic Law of Shadowsong]
Liothen has joined #crystal-lang
Liothen has joined #crystal-lang
<FromGitter>
<straight-shoota> yeah
hightower2 has joined #crystal-lang
hightower3 has quit [Ping timeout: 264 seconds]
bew has quit [Ping timeout: 248 seconds]
<FromGitter>
<straight-shoota> do you have any idea on that option? I couldn't find anything
<FromGitter>
<straight-shoota> I got time_spec to run
<RX14>
@straight-shoota I can't remember, I think it's actually just a cflag
<RX14>
Oh yeah no
<RX14>
Its for libgc
<RX14>
Not pcre
<RX14>
So you need to edit the win32.mak file to add a -D preprocessor flag
<RX14>
Its really ugly lol
rohitpaulk has quit [Ping timeout: 252 seconds]
<FromGitter>
<straight-shoota> yeah, I'll stick to adding user32.lib :P
<RX14>
well unless @asterite is investigating it anyway
<FromGitter>
<asterite> Nah, still installing stuff. I might try it on a real computer, but maybe it'll be boring to transfer files between that and the mac
<RX14>
that atexit stuff probably shouldn't be in kernel.cr
<RX14>
it should be moved to something like src/crystal/at_exit_handlers.cr
<RX14>
but thats probably out of scope of the PR...
<RX14>
so idk
<RX14>
i guess just make a kernel_spec.cr for now @bew
<FromGitter>
<bew> following your resonning, I could make an at_exit_handlers_spec and in a later PR move the actual at_exit code to a new file?
<FromGitter>
<bew> or is it better to keep kernel_spec and do all changes in the later pr?
<RX14>
either use kernel_spec.cr in this PR
<RX14>
or move the whole thing in this PR
<RX14>
and honestly kernel.cr should go
<RX14>
the top-level puts/etc/io stuff should be where STDIN is defined
<RX14>
or in io.cr
<ua>
guys im sure someone thought about it already, is it possible to have REPL under LLVM?
<RX14>
and the rest should be in Process or wherever they fit
<FromGitter>
<bew> and where should STDIN be defined? it's in kernel.cr for now
<RX14>
uhh
<RX14>
i thought STDIN was in crystal main.cr
<ua>
i mean, could crystal have something like pry in the future
<FromGitter>
<bew> at the very top
<RX14>
@ua unlikely
<RX14>
it's not to do with crystal being compiled, it's to do with crystal's type system
<ua>
ah well
<ua>
still i hope someone will figure it out some day
<RX14>
we had a repl originally
<RX14>
and we had to abandon it
<RX14>
I don't believe that we'll ever get one again
<RX14>
don't get your hopes up
<FromGitter>
<bew> can you open a small issue for this please RX14? so we don't loose track of this (I think I don't have the full picture to make this issue myself)
<RX14>
@bew it's just me rambling about crystal being a mess like always
<RX14>
Vexatos, if you went for the three dots option yes
<Vexatos>
exactly
<Vexatos>
I don't have a crystal set up right now but I would do a PR of this right from github, but it'd probably just be easier for RX14 to make the change and commit it
<RX14>
i can't commit to master Vexatos
<Vexatos>
right
<RX14>
everything is PRed
<FromGitter>
<codenoid> my grandmum is spanish
<Vexatos>
protected branches are a thing now
<Vexatos>
bless github
<Vexatos>
RX14, I mean, if everyone else is too lazy to make a PR >_>
<Vexatos>
I think the three-dot option is pretty good
<RX14>
ok
<Vexatos>
assuming none of those
<RX14>
do it Vexatos
<Vexatos>
characters turning into . are changed
<Vexatos>
err
<Vexatos>
have three-dot variants
<Vexatos>
that code seems to mangle > and < etc too
<FromGitter>
<codenoid> wow
<FromGitter>
<codenoid> glad you back
<FromGitter>
<codenoid> @aste
<FromGitter>
<codenoid> @asterite
<Vexatos>
RX14, would that also affect other chains of three of those characters?
<FromGitter>
<codenoid> somebody want your signature
<Vexatos>
e.g. ((( or >>>
<RX14>
Vexatos, we have <<
<RX14>
and >>
<FromGitter>
<codenoid> crystal is awesome for building micro service
<Vexatos>
as long as there are no chains of three
<Vexatos>
and, well, ((( is not a function
<RX14>
well
<RX14>
wouldn't >> and << mangle the same
<FromGitter>
<asterite> but we can have <<(arg)
<Vexatos>
actually
<RX14>
-> shl and shr
<FromGitter>
<asterite> and that would be ...arg.
<RX14>
yeah
<Vexatos>
wouldn't all of this mangle the same
<RX14>
the windows mangling does need a rethink
<FromGitter>
<asterite> I think we have to find some safe way to do this
<FromGitter>
<asterite> yeah
<RX14>
just
<RX14>
maybe just mangle them to .STAR.
<Vexatos>
it replaces all those characters with .
<Vexatos>
so aren't they all the same anyway?
<RX14>
I think just manging them all to .NAME. will be the best way
<Vexatos>
well, only * and + of those are functions so those are the only places where it mattered so far
<RX14>
it'll be ugly as hell
<FromGitter>
<asterite> or .1, .2, .3, etc. numbers can't appear after a dot in a method name
<Vexatos>
but >> and << are as well
<RX14>
but readable
<FromGitter>
<asterite> but probably .STAR. is better, yes
<Vexatos>
or am I missing something here
<RX14>
and ugliness doesn't really matter to me on some tiny technical detail like this
<RX14>
Vexatos, yes
<Vexatos>
meaning << and >> and ** should all reproduce this bug
<RX14>
it;s broken
<RX14>
thats what we're discussing
<Vexatos>
they should all parse as + on windows
<RX14>
not parse
<Vexatos>
well
<Vexatos>
execute
<RX14>
well the first symbol wins
<Vexatos>
yes
<RX14>
so it's undefined which will win
<Vexatos>
yup
<Vexatos>
apparently it's + though
<RX14>
so yeah just
<Vexatos>
yea just the full name
<RX14>
seperate mangling for every symbol
<Vexatos>
sounds like a gross but working solution
<RX14>
now you need to think up of short names for < and >
<RX14>
lol
<Vexatos>
someone with a windows machine to test on should do that
<RX14>
Vexatos, well I can test for you
<RX14>
once I've had my lunch
<Vexatos>
grt and lst
<Vexatos>
if you want short names
<RX14>
well
<RX14>
idk
<RX14>
it'll be ugly either way
<RX14>
it's not being used as a less-than Vexatos so i'm a tad iffy on that
<FromGitter>
<bew> yeah if you add a . at the end it's ok
<Vexatos>
could someone on winderps try this?
<RX14>
Vexatos, I *think* that should work
<Vexatos>
I don't have a windows computer to test on :I
<RX14>
@bew yep
<RX14>
Vexatos, push the commit to a fork and i'll test it
<FromGitter>
<sdogruyol> let me check vexatos
<Vexatos>
RX14, this is lowercase hex though though
<Vexatos>
so < is 3c and not 3C
<FromGitter>
<sdogruyol> need to shutdown my vm first though..
<FromGitter>
<asterite> right, we'd need to check if unicode names work too... if not, probably dot followed by codepoint is good, so we could use that as a general solution
<RX14>
Vexatos, boo hoo
<RX14>
its fine
<RX14>
Vexatos, actually
<Vexatos>
so < is 3c and not 3C
<Vexatos>
err
<Vexatos>
sorry
<RX14>
you can provide upcase: true
<Vexatos>
pasted wrong window >_>
<RX14>
to_s(16, upcase: true) Vexatos
<Vexatos>
yes
<RX14>
see crystal is perfect
<FromGitter>
<sdogruyol> haha lol
<FromGitter>
<sdogruyol> vexatos, it works
<Vexatos>
nice
<FromGitter>
<sdogruyol> tried it on puts 10 ** 0
<RX14>
@sdogruyol and you tested that it didn't work before?
<FromGitter>
<sdogruyol> yes?
<FromGitter>
<sdogruyol> I'm sorry, what's your point?
<FromGitter>
<ArtLinkov> is there a command in crystal which is similar to shape from python?
<FromGitter>
<bew> I'm not sure I understand exactly what it does, maybe you're looking for `Enumerable#in_groups_of` https://crystal-lang.org/api/0.24.1/Enumerable.html#in_groups_of(size%3AInt%2Cfilled_up_with%3AU%3Dnil)forallU-instance-method (note: Array is an Enumerable, so all methods in Enumerable are available for Array)
<FromGitter>
<ArtLinkov> lets say I have an array(array(array(T))) and I want to create a similar object but empty or with other values. I can use shape to create it
<RX14>
@sdogruyol my point was you need to make sure you're testing it correctly before you can test it's fixed :)
<FromGitter>
<sdogruyol> I'm pretty aware of that RX14
<Vexatos>
commit message might be too long, I don't know
<FromGitter>
<sdogruyol> not sure what made think that I'm not doing that
<FromGitter>
<sdogruyol> made you*
<RX14>
just making sure...
<FromGitter>
<sdogruyol> thank you vexatos
<RX14>
Vexatos, commit messages should be imperative
<Vexatos>
It makes me feel uncomfortable that I am about to PR something I have not tested myself
<RX14>
and less than 52 chars
<RX14>
Change symbol mangling on windows to avoid conflict
<RX14>
that's what I would have called it
<Vexatos>
all my repos usually have fairly long commit messages
<Vexatos>
so that's why I asked :P
<FromGitter>
<bew> @ArtLinkov I don't think we have this in the stdlib, also it looks like a very specific thing used for datasets, change their shape etc.. maybe a shard oriented in this field might do that idk. Let's ping @bararchy maybe he already had to handle this kind of things
<RX14>
the implementation details are in the diff Vexatos
<RX14>
the intention should be in the commit message
<RX14>
commit messages are an art
<Vexatos>
well, rename pushed
<RX14>
Vexatos, no full stops either
<RX14>
it's not a sentence
<FromGitter>
<straight-shoota> details could be in a second line but I think it is pretty obvious what
<FromGitter>
<straight-shoota> I can also confirm that it works if that helps you feel more comfortable
<crystal-gh>
[crystal] Vexatos opened pull request #5518: Change symbol mangling on Windows to avoid conflicts (master...windows-mangle-fix) https://git.io/vbjQe
<FromGitter>
<bew> no, your example will work fine! I mentioned first the version of reduce which take an initial value, like in `[1, 2].reduce(3) { |acc, i| acc + i }` wich gives 6 (note the initial value of the accumulator), and I said just after that the other form without initial value would have an accumulator initialized to 0, which is false, it is initialized to the first value of the enumerable
<FromGitter>
<vpereira> ah ok, thank you @bew !
DTZUZU has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei_ has joined #crystal-lang
snsei has quit [Ping timeout: 272 seconds]
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]
alex`` has quit [Quit: WeeChat 1.9]
<FromGitter>
<asterite> vpereira: sum already exists in Enumerable
<FromGitter>
<asterite> if it's for the last pr, it can be merged. That code only runs on windows so even if you have a typo there or some bug it won't get caught by ci
<crystal-gh>
crystal/master 288af4b Benoit de Chezelles: Refactor init spec (#4915)
<RX14>
@asterite no it's a general complaint
<dragonkh>
evening :)
alex`` has quit [Quit: WeeChat 1.9]
faustinoaq has joined #crystal-lang
flaviodesousa has quit [Ping timeout: 268 seconds]
aroaminggeek has quit [Ping timeout: 240 seconds]
alex`` has joined #crystal-lang
rohitpaulk has joined #crystal-lang
dragonkh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dragonkh has joined #crystal-lang
bmcginty has quit [Ping timeout: 240 seconds]
rohitpaulk has quit [Ping timeout: 260 seconds]
bmcginty has joined #crystal-lang
claudiuinberlin has joined #crystal-lang
alex`` has quit [Quit: WeeChat 1.9]
aroaminggeek has joined #crystal-lang
aroaminggeek has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<RX14>
@asterite btw, if you're investigating why --emit doesn't work when cross-compiling, can you solve the bc_flags file being created when cross-compiling too...
<FromGitter>
<asterite> what's wrong with that?
<RX14>
well
<RX14>
I didn't ask for a random bc_flags file being created @asterite
<RX14>
i never use it and it just gets in the way
<RX14>
it seems a bug to me that it's created in the first place
<RX14>
i mean the bc_flags gets created in the current directory
cremes has quit [Quit: cremes]
<FromGitter>
<asterite> Oooh... yeah, that's not good
<RX14>
@asterite just if you're hacking on that part of the compiler anyway I thought i'd give you a heads up
<crystal-gh>
[crystal] bew opened pull request #5520: Remove `bin/crystal` usage for init tool specs (master...spec-init-programatically) https://git.io/vNeWq
<FromGitter>
<asterite> I just found out that the `**` method mangling was conflicting with `>>`
<RX14>
oh yeah that makes sense
<RX14>
10 >> 0 or 10 << 0 would both be just 10
aroaminggeek has joined #crystal-lang
<Vexatos>
wasn't that what I predicted a few hours ago?
<crystal-gh>
[crystal] asterite opened pull request #5522: Benchmark.ips: show allocated bytes per operation (master...feature/benchmark-ips-allocs) https://git.io/vNeXk
<RX14>
@asterite I think we might need va_list support for the windows port...
<RX14>
stuff like for example snprintf just isn't a symbol on windows
<RX14>
you *have* to use vsnprintf
<RX14>
the snprintf is an inline def in the header files
<RX14>
which calls vsnprintf
<RX14>
and va_list is just a pain...
<RX14>
I wish we didn't need printf...
<FromGitter>
<asterite> there's a pr from makenowjust to support that, I already approved it some months ago
<RX14>
i don't think so
<RX14>
from my limited understanding that's unpacking va_list only
<RX14>
I think it's only a limited implementation for callbacks