p0p0pr37 has quit [Read error: Connection reset by peer]
p0p0pr37 has joined #crystal-lang
p0p0pr37 has joined #crystal-lang
faustinoaq has quit [Ping timeout: 265 seconds]
faustinoaq has joined #crystal-lang
Raimondi has quit [Quit: WeeChat 1.9.1: ¡Chau!]
Raimondi has joined #crystal-lang
hightower3 has joined #crystal-lang
hightower2 has quit [Ping timeout: 265 seconds]
rohitpaulk has joined #crystal-lang
duane has joined #crystal-lang
<FromGitter>
<bararchy> Da fuck `Dah for some reason thought it compiles to JVM `
<FromGitter>
<bararchy> Who the hell thinks a.compiled language will run willingly on JVM XD
krystal has joined #crystal-lang
krystal has quit [Client Quit]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<FromGitter>
<bew> @OvermindDL1 note: Crystal does not compile to JVM, it compiles to *native code* not to JVM bytecode
snsei has quit [Remote host closed the connection]
sz0 has quit [Quit: Connection closed for inactivity]
duane has quit [Ping timeout: 240 seconds]
johndescs_ has joined #crystal-lang
johndescs has quit [Ping timeout: 250 seconds]
johndescs_ is now known as johndescs
<OvermindDL1>
bew: Huh? When did I ever say that? I know it compiles to native via LLVM.
<OvermindDL1>
What are you taking about?
<OvermindDL1>
I think you meant andre1sk, not me
snsei has joined #crystal-lang
<FromGitter>
<bew> oh yeah sorry about that I misread everything ^^
<OvermindDL1>
Lol
<OvermindDL1>
I may find Ruby and Crystal and Elixir syntaxes absolutely abhorrent, but I know decently how each work. 😉
* OvermindDL1
considers any language with a GC fundamentally broken as it focus on only one type of resource management instead of all resource management as well as it's an uncontrollable manager in the significant majority of cases
<OvermindDL1>
focuses*
<OvermindDL1>
I would never touch elixir if I could but the beam vm makes it almost stupid easy to scale. I can do the same in c++ sure but significantly more work, work that is not worth it to get the same guarantees that the beam gives
<FromGitter>
<girng> @bararchy was quoting a post on elixir forum xD
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<FromGitter>
<girng> @OvermindDL1 long time no see how r u doing
<FromGitter>
<girng> hows this look for a simple server tickrate per game instance? https://paste.ee/p/gM1nw
snsei has quit [Remote host closed the connection]
<FromGitter>
<girng> you know what, now that i think of it. since i have my masterserver created so well, t hat it syncs with my game servers (cheap VPSs). and since crystal is just using 1 core. if the vps i buy is a dual core, i could actually load up two game servers, one on each port. for example, 9300, and 9301. ⏎ however, im looking to buy cheap VPSs and those cheap ones are usuually a quarter of a core, lol. for example, the
<FromGitter>
... one i have now is just giving me 600MHz on a `E5620 @ 2.40GHz`. which isn't even 1 full single core access lol. ⏎ ⏎ btw, @bew and bar Hofesh.. i don't know if u remember, but a couple days ago when i posted my server specs on my vps remember it was 500MHz? well, i went to re-install the OS and it failed. so i made a suppo ... [https://gitter.im/crystal-lang/crystal?at=5afd1d262df44c2d06344c92]
<OvermindDL1>
Laying in bed. Passing out... 😅
<FromGitter>
<girng> @OvermindDL1 did you go to university?
<OvermindDL1>
I teach and work at a college?
<FromGitter>
<girng> @OvermindDL1 oh, figured lol. you seem very educated =]
<FromGitter>
<girng> why i asked
<FromGitter>
<girng> cause you helped a lot couple weeks ago with my questions with elixir n stuff
<OvermindDL1>
Eh, more industry knowledge that educated knowledge, I worked at Xerox for over 8 years before my current job
<OvermindDL1>
Than*
<FromGitter>
<girng> wow
<OvermindDL1>
Ehh, I'll leave it at that, not a job I'd want to do again for moral reasons...
<FromGitter>
<girng> only job I had was a caregiver at a nursing home. i went to college for an associates and got a CIS certificate. (pell grant, totally free). i had the option to xfer to a university, to get a bachelors. but i stopped, because college seemed like high school 2.0. it was boring, just a waste of time and i made no connections with friends
<FromGitter>
<girng> came out of college just as empty as high school
<OvermindDL1>
It was, honestly for most degrees you don't go to school to learn, you go for that piece of paper. Some degrees are worth school, like nursing, but not programming or IT
<OvermindDL1>
I'm not sure I'd hire someone that learned programming in school...
<FromGitter>
<girng> my CIS professor was insanely nice though, that's all i remember. like 70 year old, he used to program back in the day too lol
<OvermindDL1>
Hehe, those people are fun
<FromGitter>
<girng> ya you would probably hire them on more of their experience and knowledge, than a degree, right?
<OvermindDL1>
Show me a GitHub repo of their work yeah, I can see how their coding is, how they interact in issue communications, PR details, etc...
<OvermindDL1>
It is pretty obvious when someone is coding without understanding what they are writing
<FromGitter>
<girng> yeah, it seems like how they conduct themselves and their programming history far succeeds a piece of paper
<FromGitter>
<girng> but i guess the degree is nice to have too, i guess
<OvermindDL1>
HR likes the degree, no one else does
<OvermindDL1>
And you have to get through HR first
<FromGitter>
<girng> haha, good point
<OvermindDL1>
I have two degrees and a minor, none did me a lick of usefulness after HR
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven`` has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.1]
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven`` has joined #crystal-lang
Ven`` has quit [Ping timeout: 240 seconds]
<FromGitter>
<girng> is it more expensive to parse a float 32 with 2 decimals, or a string that's the same length?
<FromGitter>
<yxhuvud> Can you please rephrase the question? It really doesn't make sense as it is now.
mps has joined #crystal-lang
<FromGitter>
<girng> sorry. basically, "5234.51" coming in from JSON::Any,and you read it with number.as_f (float 32). compared to number.as_s (as a string). is it about the same, in terms of efficiency?
<FromGitter>
<girng> `as_f32` oops.
<FromGitter>
<yxhuvud> I doubt there will be a relevant change, but I'd suggest you benchmark it yourself if you want to know. See https://crystal-lang.org/api/0.24.2/Benchmark.html for some help on how to do that
<FromGitter>
<girng> ok yeah good idea forgot about benchmark tool xD
alex`` has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
DTZUZO has joined #crystal-lang
DTZUZO has quit [Client Quit]
<FromGitter>
<Grabli66> Hi! What is the best way to make plugin in crystal? Plugin for app that also written in crystal.
<mps>
do any of you use crystal in financial apps? I have some fear because it is in alpha state
<FromGitter>
<girng> not sure if @sdogruyol's app is financed related, but he uses crystal in production
<mps>
girng: I tested some of my apps in perl with crystal version and the results looks ok
<FromGitter>
<girng> o really? nice
<FromGitter>
<girng> i could never get into perl
<FromGitter>
<girng> i've always wanted to try it out however
<mps>
but, it would be nice to know if someone experienced in crystal can share opinion about that domain of use
<FromGitter>
<girng> i will ping @sdogruyol for you, he can help answer. sorry i can't
<mps>
girng: perl is not hard to learn
<FromGitter>
<girng> can perl be used for tcp server?
<mps>
it have bad 'image' because it is not 'academic' language
<mps>
but most and best languages are not born in academia, anyway :)
<mps>
girng: yes, there are a lot of TCP servers in Perl
<FromGitter>
<girng> really? epic can u give me a example of a lightweight simple one
<FromGitter>
<girng> does it work across multiple processes is perl single core like crystal?
<mps>
well, Perl supports fork(2) quite well, but threads are not so good
<FromGitter>
<girng> eh
<FromGitter>
<girng> iuno man, i'll check perl out but if i were to move to a new language, i'd want multi core support out oft he box, similar to elixir.
<FromGitter>
<girng> but im too deep anyway i was just curious hahaha
<mps>
I have perl HTTP servers in production real-time and critical apps which works for more than 10 years
<mps>
it is not without problems, but I didn't found anything without problems till now :)
<FromGitter>
<girng> how many requests you getper month?
<FromGitter>
<girng> on that http server
<mps>
didn't count, but daily (from the head) it servers hundreds of thousands requests
<FromGitter>
<girng> oh wow lol
<mps>
it is RESTfull services
<FromGitter>
<bararchy> perl programming is bsiclly `Shift` + number keys :)
<mps>
actually, I made some of my perl servers in crystal (well, not complete) for tests
<mps>
it works quite fine, but I'm still learning crystal so I have bugs and problems
<mps>
I'm trying to comprehend crystal reading ruby book, and that is 'try and error' method :)
<mps>
but, as Lewis Carol told in 'Alice in wonderland' "you will learn, my dear. You will learn!"
<FromGitter>
<girng> /master docs when scrolling on firefox = insane lag
<FromGitter>
<girng> did someone change the scroll behavior plz change it back xD
<FromGitter>
<sdogruyol> @mps I've used Crystal extensively with critical payment stuff
<FromGitter>
<sdogruyol> what's your use-case?
<mps>
sdogruyol: nice to hear. I'm working in on-line service where we calculate monthly invoices for users
<mps>
till now all calculations are in perl, with some help of C
<mps>
I'm learning crystal, and would like to move some services to crystal
<mps>
but my fear is about sentence 'crystal is alpha state' which I read somewhere on crystal-lan.org IIRC
<wuehlmaus>
doesn't feel like alpha at all. I think it's only a warning that the behaviour could change fast. but stability wise it feels quite stable IMO
<wuehlmaus>
but, okay, i don't use in production so ...
<wuehlmaus>
^ it
<mps>
wuehlmaus: well, I also have that feeling, but it is not unwise to hear from other with a deeper experience
<wuehlmaus>
yes, very good idea!
<livcd>
well i would definitely not use Crystal for something mission critical
Ven`` has joined #crystal-lang
<FromGitter>
<girng> so i did some testing with my game server.. each new game class that get instanced, spawns a 15hz tick rate. i spawned 1000 of them. so t hat's over 15,000 iterations per second
<FromGitter>
<girng> cpu % in `top` fluctuated around 0.2 to 5% lol
<mps>
livcd: is your opinion from experience or just thougt. could you tell little about it
<mps>
I would like to hear pro end contra
<livcd>
it's ofc subjective opinion
<mps>
ok, sometimes gut feeling is better than rational explanations, in my experience at least
<FromGitter>
<girng> i think he's saying you should be fine, unless you are using it for NASA, or like flying drones, etc
<FromGitter>
<girng> simple restful API or w/e you should be more than fine
<mps>
girng: long time ago I worked in ballistic calculations and then I learned how the computers are bad at math
<mps>
from that time I always triple check everything
<FromGitter>
<girng> lol
<livcd>
well people use proprietary niche technologies and are doing just fine
<livcd>
RubyMotion is still used and it's maintained by 1 guy only if i recall correctly
<mps>
I don't see any problem if something maintained by 1 person if well designed, tested and carefully looked
<mps>
s/if well/is well/
moei has quit [Quit: Leaving...]
<FromGitter>
<sdogruyol> @mps that one service in Crystal had like more than 1.5 years uptime with no restarts :P
<FromGitter>
<sdogruyol> talks to weird SOAP banking apis and does some crazy xml parsing
<FromGitter>
<girng> how can i access another value outside of a class?
<mps>
sdogruyol: yes, I know. Thank you for sharing your experience
<FromGitter>
<sdogruyol> anytime!
<mps>
ok, I will start to work on test system with crystal
<FromGitter>
<sdogruyol> go for it
<FromGitter>
<sdogruyol> I'm sure that it's worth a shot and you're gonna like it :)
<mps>
sdogruyol: Well, I'm still learning crystal and in my experience the best method to learn something is to do a real work with the learning subject
<FromGitter>
<girng> i think i got it. i need to use `class_property`
<FromGitter>
<sdogruyol> @mps absolutely!
<mps>
it is somehow slow but the results are good
<mps>
sdogruyol: btw, are you author of Kemal framework
<FromGitter>
<sdogruyol> yes
<mps>
Nice work. I looked at it to learn about REST and HTTP crystal solutions :)
<FromGitter>
<sdogruyol> thanks a lot! Glad you liked it 👍
<FromGitter>
<girng> actually. im keeping track of my game tick rate iterations.. and it stops at around 500 games open. which is around 500 fibers, each having their own 15hz loop do. which is around 7,500 iterations per second. after that, the fibers just stop working
<FromGitter>
<girng> im going to now test, just one main game loop at 15hz, that iterates over the games, and players instead. see how many games i can get open =]
<FromGitter>
<girng> hmm that's odd. even when the fibers stop, when i look at the process in `top`, it still shows crystal not even at max load. so i think something else is screwy.
<FromGitter>
<girng> im going to isolate this in my own file and test it out separately. needs to be reduced
greengriminal has joined #crystal-lang
<FromGitter>
<sdogruyol> are you sure that you're not io bound @girng?
<FromGitter>
<girng> @sdogruyol not sure, can i check that in `top`? i'll post this mini example here in a min 1 second
<FromGitter>
<girng> i can get up to `Total Game Loop Iterations: 391000, Games Open: 1000`... which is far more than my total of 300 on my real gameserver. i wonder if socket.send has anything to do with it. i bet that is part of the `IOTOP` part
<FromGitter>
<girng> i can actually increase it further than that cpu usage is still low as heck
greengriminal has joined #crystal-lang
<FromGitter>
<sdogruyol> well that means you're locking up the event loop and not cpu bound
<FromGitter>
<sdogruyol> how's your memory usage e.g?
<FromGitter>
<girng> forgot to check memory let me try on real gameserver
<FromGitter>
<girng> definitely IO bound right, cause send?
<FromGitter>
<sdogruyol> yeah
<FromGitter>
<sdogruyol> I assume those are websockets?
<FromGitter>
<girng> just regular tcp server from api page
<FromGitter>
<sdogruyol> if so then publishing to all of those is gonna some bandwith
<FromGitter>
<sdogruyol> well still those are sockets = network
<FromGitter>
<girng> well yeah
<FromGitter>
<girng> so, doing the game loop in each fiber isn't issue. more io bound. which means me testnig the 1 game loop, and iterating through games is pointless to test
<FromGitter>
<girng> fibers pretty damn powerful
<FromGitter>
<sdogruyol> it's Crystal power
<FromGitter>
<sdogruyol> :)
<FromGitter>
<girng> so that socket io is basically means my local speeds are just not fast enough, right?
<FromGitter>
<girng> bcz memory and CPU in top still very low
<FromGitter>
<girng> if i buy a vps, it will need high port
<FromGitter>
<girng> right?
<FromGitter>
<girng> not 100mbps, but 1000mbps
<FromGitter>
<girng> "gig port" or w/e lol
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter>
<bararchy> @girng Do you have a demo running?
<FromGitter>
<girng> locally lol
<FromGitter>
<girng> stupid iotop don't work on WSL
<FromGitter>
<girng> but really. even if i could get 500 games active on a VPS, that's still AMAZING. 6 players per game, that's 3,000 online players. which is far more than i prob will ever get lol
<FromGitter>
<girng> i mostly just want the extra VPSs, because i want to place them around the world, so players don't experience lag
rohitpaulk has quit [Ping timeout: 256 seconds]
<FromGitter>
<bararchy> @girng I'm gonna get a beta key? ;)
<FromGitter>
<yxhuvud> you could perhaps not send all data every time and improve performance that way
<FromGitter>
<girng> sure, i generate with `UUID.random` :D
<FromGitter>
<bararchy> LOL
<FromGitter>
<girng> lol actualyl, i will probably do that. and put them in mysql so when a player uses it, it'll remove the beta key and set access =true to play :D
<FromGitter>
<bararchy> Will you have Steam\GOG client support?
<FromGitter>
<girng> nah, just linux and windows native. my game has microtransactions, don't want steeam taking my $
<FromGitter>
<girng> they take %
<FromGitter>
<girng> anyway, i'm going to add in socket io to my example (https://paste.ee/p/PtaGX), so i test it / reduce it by itself brb
<FromGitter>
<mamantoha> @bararchy thanks. Restarting dynos on Heroku resolves problem :)
<FromGitter>
<bararchy> Thanks :)
<FromGitter>
<bararchy> 🎉
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven`` has joined #crystal-lang
Ven`` has quit [Client Quit]
Ven`` has joined #crystal-lang
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
greengriminal has joined #crystal-lang
Ven`` has joined #crystal-lang
rohitpaulk has joined #crystal-lang
greengriminal has quit [Ping timeout: 248 seconds]
rohitpaulk has quit [Ping timeout: 256 seconds]
faustinoaq has joined #crystal-lang
<FromGitter>
<faustinoaq> > `shards.info` is down with Kemal 500 error :( ⏎ ⏎ @mamantoha Would be interesting to see how many resources (RAM, CPU, etc) do `shards.info` use? Maybe you can share us 😅
<FromGitter>
<faustinoaq> > Restarting dynos on Heroku resolves problem :) ⏎ ⏎ Thank you! 😄 ✨
<FromGitter>
<r00ster91> What about adding a `--no-gc` flag or something to completely disable the GC? Then Crystal will be even more faster and closer to C speed. And eventually compile times would be faster. I know garbage collecting is important sometimes and useful so you don't need to manage the memory yourself but sometimes at pretty simple programs theres just not a GC needed. And then it would be nice that you can disable it.
<FromGitter>
... ⏎ ⏎ I know its possible to redefine the normal main function so `GC.init` doesn't runs but it would be still really good and quite handy to have a flag for this that the user can specify instead of needing to redefine it first.
<faustinoaq>
I found some outdated syntax on that file :-)
<faustinoaq>
I just realize of that when I was trying to test my code for crystal syntax support on Kate https://phabricator.kde.org/D7909
<faustinoaq>
:-)
<FromGitter>
<girng> @r00ster91 if no GC, we then manually clean up classes in their destructor?
<FromGitter>
<r00ster91> yes. But whats with really simple little programs without classes which really dont need a GC?
<FromGitter>
<girng> too advanced 4 me, i wait for rx14+other master devs to chime in sry
<RX14>
you can turn off the gc
<RX14>
it wont make your programs much faster
<RX14>
and it won't make them compile faster
<RX14>
and you'll run out of memory pretty quick
faustinoaq has quit [Ping timeout: 265 seconds]
<FromGitter>
<r00ster91> hm I thought the compile times were faster when I once redefined the main function. And didnt you said some time ago that the only thing thats keeping crystal from being fast as C is because its a GCd language? I think it would be still handy to have a flag for this.
<RX14>
it's 10% speed for a non-solution
<RX14>
C provides manual memory management
<RX14>
thats impractical in crystal
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
DTZUZO has joined #crystal-lang
<FromGitter>
<S-YOU> -Dgc_none exists
<FromGitter>
<S-YOU> But bohem gc 's GC_malloc is much faster than C's malloc at same amount of call.
<OvermindDL1>
Theoretically a GC can handle memory better than traditional malloc/free, however the tracing style to keep the root's of the memory is generally what incurs the main overhead
<OvermindDL1>
Heh, very, someone brought it up in another channel on another network and I was trying to get my bot to print it out, which it obviously does not do here... ^.^;
<FromGitter>
<S-YOU> I do think that your password was `malloc`
ua has quit [Ping timeout: 240 seconds]
ua has joined #crystal-lang
sz0 has joined #crystal-lang
<oprypin>
i officially declare bitbucket as the website with the worst UI in the world
<OvermindDL1>
It is pretty bad, but unlimited private repo's though, before gitlab existed...
<OvermindDL1>
And it is faster than gitlab
<RX14>
self-hosted gitea seems the way to go
t0nyandre has quit [Quit: Account terminated by the PanicBNC Staff Team.]
<RX14>
or just become an academic and get free github private repos
<OvermindDL1>
Eh but then have to contend with losing access when you leave that then, or paying
<OvermindDL1>
github doesn't have a good way to recover things in a variety of ways
<RX14>
true
<RX14>
but at the end of the day it's git
<RX14>
and you should have backups anyway
<RX14>
my stuff is rsynced every 5 mins to my nas
<RX14>
and from there backed up incrementally daily to two cloud providers
<OvermindDL1>
Hear hear
<RX14>
private repos just provide easy access, you shouldnt really rely on them for backup
<RX14>
i spend probably a bit too much money in not bitrotting my own stuff
<FromGitter>
<bew> What do you rely on for backups?
<RX14>
I use duplicacy, which is an extremely nice piece of software but unfortunately only visible source
<RX14>
when restic gets sparse file, deletion, and compression support then i'll move to that
<FromGitter>
<Wulfklaue> Guys, i am sorry to say this but i will be moving to Go ( *yuck* ) for a rather large project. ⏎ ⏎ I have been following ( for over a year ) and financially supporting Crystal for a long time behind the screens but this lack of progress is detrimental to my projects. ⏎ ⏎ The whole progress from Manas looks to be nothing. There last effort dating back months being the CircleCI 2.0 may have had
<RX14>
bcardiff will be starting work on crystal full-time next week
<RX14>
there are plenty of good other reasons to move to go though
<FromGitter>
<r00ster91> when im running my program after i already runned it before and i made no change to my file, why is crystal not just caching the executable and running it again then instead of building it completely again? because it will just build the exactly same thing. so caching would be much smarter and faster
<RX14>
that could be done with crystal run just by a hash of all required files
<RX14>
but it wouldn't work for crystal build
<RX14>
it's just a low-priority enhancement
<FromGitter>
<girng> wat just happended
That_Guy_Anon has quit [Quit: Leaving]
txdv has quit [Ping timeout: 264 seconds]
txdv has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
alex`` has quit [Quit: WeeChat 2.1]
alex`` has joined #crystal-lang
alex`` has quit [Read error: Connection reset by peer]
<FromGitter>
<fridgerator> dude bailed
* FromGitter
* manveru just coming from go....
<FromGitter>
<manveru> i just wish static compiling was as easy
<oprypin>
i ran nix in a vm once for like 15 minutes, so i guess things are pretty serious
<FromGitter>
<manveru> :)
<FromGitter>
<manveru> basically it makes it possible to build crystal projects that depend on shards with nix
<FromGitter>
<manveru> i did similar stuff for yarn/rubygems/elm-packages/guile/vim, since they each insist on having their own half-assed implementation of half of nix
manveru has left #crystal-lang [#crystal-lang]
hightower2 has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
<hightower2>
Hey, can I invoke a macro on an object directly somehow? I notice that if I do obj.some_method, and that method calls a some_macro, that works. But if I do obj.some_macro, that doesn't work.
<oprypin>
hightower2, macros are never associated with an object. that would make no sense because an object's state is entirely run-time
<hightower2>
yes, sure, but I would expect it would somehow still expand. Although I probably answered it by asking... it would be questionable how would obj.some_macro expand a macro into anything useful
<hightower2>
So, invoking a method, which called some macro internally and now has the code that macro inserted, is the way to go?
<OvermindDL1>
Eh, I could see macro's being associateable with an object if it's type was known at runtime (and it didn't use something horrible like OOP or so)
<oprypin>
hightower2, that's the only thing that makes sense, yes
<hightower2>
Great, thanks for confirming/clarifying oprypin
<oprypin>
github.com homepage improved
greengriminal has joined #crystal-lang
greengriminal has quit [Client Quit]
<hightower2>
mm, interesting change
alex`` has quit [Quit: WeeChat 2.1]
<hightower2>
I am calling a macro with a block as argument ( some_macro "x", { block code } ). Is it possible to somehow compute a .hash() of that block within the macro? If I just do {{block}}.hash, that seems to execute it or in some other way not do what is wanted
<oprypin>
hightower2, would you write { block code }.hash ?
<oprypin>
cuz that's what this ends up as
<oprypin>
what are you actually trying to do?
<hightower2>
I'd like the effect to be something like def my_method(&block) puts block.hash end
<hightower2>
But need to do it in the context of a macro
<oprypin>
what are you actually trying to do?
<hightower2>
Good question :) Let me try phrasing it :)
greengriminal has joined #crystal-lang
greengriminal has quit [Quit: Leaving]
<hightower2>
On a side note, why does some_macro { |x| puts x } work, while some_macro "arg1", { |x| puts x } produces "unexpected token: |"
<hightower2>
must be in the second form it is being treated as a tuple or hash
<oprypin>
hightower2, perhaps my examples will help you come to the right conclusion
<oprypin>
you should note that you're not supposed to write a comma when passing a block, then it just doesn't work
<oprypin>
then it's something entirely different, seems equivalent to `begin; end` rather than `do; end`
<hightower2>
yeah, managed to get it working by doing some_macro("arg1") { block }, and explicitly adding & macro definition, so it's macro some_macro(arg, &block)
<oprypin>
that is correct
<oprypin>
and i was incorrect, it really is a tuple then
<hightower2>
As for what I was trying to do with block.hash above... I have macro to which I pass blocks, and it stores them somewhere. As its return value, I would like it to return the block's hash, so that later I can use the hash value to iterate through existing blocks and delete the one(s) matching the hash
<hightower2>
But if I'm making a mistake somewhere and finding/removing blocks can be done without a hash (or using some other way of tracking/finding the right ones), I'm all ears
<hightower2>
oh solved it.. my macro in turn calls some method which returns the hash, so I don't need to compute it while in macro context