sferik has quit [Read error: Connection reset by peer]
asterite has joined #crystal-lang
<asterite>
zamith: you can use `private getter foo` just fine :)
<asterite>
but you can't do `private\ngetter foo`
<asterite>
we decided we didn't like the `private` in the middle of the code... then you have a method and you can't immediately tell if it's private or not, you have to scroll up to see if there's a `private` somewhere
<asterite>
So you can do `private def` or `private macro_call` and the private will be applied to everything the macro creates (like in the case of getter)
<jhass>
can I check if a constant is defined in a macro?
<asterite>
Not yet
<asterite>
I tried to compile cebot, I get`Assertion failed: ((i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!"), function init, file Instructions.cpp, line 281.`
<asterite>
Don't worry, I'll take a look at it one of these days, I'm actually more interested in your code (it looks pretty rubyesque) than running the bot right now :)
<jhass>
does it? I feel like I'm actually overdoing the type restrictions
<asterite>
I think I actually like that. It makes the code more clear in some cases
<asterite>
Your code looks very magical and very, very well organized
<asterite>
I can't write code like that :( My code tends to become spaghetti after a while
<jhass>
that sounds kinda contradictish :P
<asterite>
I also couldn't understand how the "add_plugin" worked because there's a macro and a def, but it's an interesting trick :)
<asterite>
Why contradictish?
<jhass>
contradicting ;)
<asterite>
Why contradicting? :)
<jhass>
magical to me means hard to understand, well organized otoh. means easy to follow ;)
<asterite>
Ah, by magical I mean that I read the code and I understand the intent, like the way you create a Bot with add_plugin, or the way you define a plugin with a `match` macro
<asterite>
Very DSL-ish
<asterite>
That doesn't mean it's not well organized
<jhass>
oh ok
<asterite>
By the way, what do you think of `property!`?
<asterite>
I like DLSs too. And I think all that indirection (but it's actually refactored and readable code) goes away when you compile in --release, just like invoking a private getter vs using an instance var ends up being the same
<jhass>
well, what the ! variant does I see as a necessity, about the name, I think I like it by now, it just too some time to not write attr_* while still having the feeling of writing Ruby ;)
<jhass>
since that's what it still does to me mostly, writing Crystal to a large extent feels like writing Ruby
<asterite>
That's good :). I feel it that way too, but I always have "avoid nilable types" in my mind when I program crystal
<asterite>
plus other things, maybe
<asterite>
Another question: how long it takes to compile the bot?
<jhass>
uh, about a second I think
<jhass>
should run with --stats
<asterite>
I guess that's with the unoptimized compiler you created, right?
<jhass>
the debug one? no, that one never finished to compile
<jhass>
Parse: 00:00:00.1959200
<jhass>
Type inference: 00:00:00.4902530
<jhass>
Codegen (crystal): 00:00:00.2636440
<jhass>
Codegen (bc+obj): 00:00:00.4957380
<jhass>
Codegen (clang): 00:00:00.1485990
<jhass>
let me try after wiping the cache
<jhass>
Parse: 00:00:00.1637160
<jhass>
Type inference: 00:00:00.4887440
<jhass>
Codegen (crystal): 00:00:00.2688020
<jhass>
Codegen (bc+obj): 00:00:00.6212620
<jhass>
Codegen (clang): 00:00:00.1543470
<jhass>
so, the delay that made it feel like a second is actually the network connect I guess
<asterite>
Network connect?
<jhass>
when doing crystal src/main.cr to run it right away
<jhass>
so it feels like a second or two until the first output
<asterite>
Ah! I understand :)
<jhass>
which should be the TCP handshake
<asterite>
You can try with crystal build src/main.cr
<asterite>
But, good, it's pretty fast, I guess
<jhass>
yeah I did, see ^ stats output ;)
<asterite>
I started watching handmade hero and the guy really hates makefiles. He says: the time it takes to compile all the files over and over again might take, like, for a big project, maybe three or four seconds. But that way I save a lot of time by not having to deal with makefiles and other "build" tools
<jhass>
I hate Makefile's too
<jhass>
I like rake though
<jhass>
it's actually way more powerful than most people notice
<asterite>
I'll also take a look at your core_ext. I think we have partition, it's in Enumerable
<jhass>
oh, did I write it without trying after I didn't see it in Array? that might be :D
<jhass>
looks like it, dropped, thanks ;)
<asterite>
I think your project might be the largest one, after the compiler :)
<jhass>
mmh
<jhass>
maybe
<jhass>
it's designed to be essentially at least 3 projects though :D
asterite has quit [Quit: Page closed]
sferik_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
asterite has joined #crystal-lang
<asterite>
jhass: I know this might sound hard to believe, but I had this source file (uncommited) on my machine just because it worked and it can make synchronization easy, and it's a cool trick: https://gist.github.com/asterite/7d2da9d866176f039add
<jhass>
:D
<asterite>
I guess we are in sync ;-) (pun intended)
<asterite>
I skimmed through your code, you have a lot of pull requests to send us there!
<asterite>
There's even Thread#name=, that Ruby doesn't have. I didn't know threads could have a name
<jhass>
yeah, I learned that yesterday
<jhass>
did you look at CheckingMutex? The semantics may need some additional work, but I think it should actually be the default
<jhass>
mainly to have a reentrant mutex (and recursive mutex is actually not good for that since it doesn't allow to use condition variables when nested)
<asterite>
I don't know much about pthread mutexes (or mutexes at all, for that matter), but I believe you :)
<asterite>
Do you find having to specify a block's type when it is captured annoying?
<jhass>
I learned that all the past days, so maybe I'm missing something too
<asterite>
For those things I have to check with waj, which seems to know pretty much anything about computers :-P
<jhass>
a bit maybe, but it's okay
<asterite>
What does Char#in_character_specs? do?
<jhass>
Array#count
<jhass>
at least I hope I managed to to match those semantics
<jhass>
blergh, String I mean
<asterite>
You mean String#count?
<asterite>
Ah, good :)
<jhass>
in Ruby several methods the String#count semantics, String#squeeze is one example, String#delete too actually I think
<jhass>
*use the
<jhass>
sorry, it's too late here :)
<asterite>
Hehehe, no problem :)
<asterite>
I found out the problem for the segfault on my side. It's because of pthread_mutex_init. Apparently it's using master's version for some reason (they both have the same mangled name, so maybe it choses that randomly, I don't know)
<asterite>
I guess we can fix that by erroring if two libs, whenever they are, define a C function with different signatures (in your case instead of trying to monkey-patch that you would need to submit a pull request with the fix)
<asterite>
But... I'm going to sleep now, so I hope you too ;)
asterite has quit [Ping timeout: 246 seconds]
bcardiff has quit [Quit: Leaving.]
sferik has joined #crystal-lang
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
canhtak has joined #crystal-lang
sferik has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
canhtak has quit [Quit: canhtak]
zamith has joined #crystal-lang
canhtak has joined #crystal-lang
canhtak has quit [Ping timeout: 252 seconds]
leafybasil has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
bcardiff has joined #crystal-lang
asterite has joined #crystal-lang
<asterite>
jhass: To be honest, when you said your code was a mess I imagined one huge file with lots of regexes for the bot :-P
<asterite>
I wouldn’t call your code a mess
<zamith>
asterite: hey, I did some refactoring on the lexer string tests
<zamith>
have you seen it?
<zamith>
I mostly wanted feedback on the approach
<asterite>
I just had time to skim through the code. I really like it that you are trying to refactor the existing code, it’s very needed and the less code we have, and the more readable it is, the better :)
<zamith>
yeah, I find it hard to navigate through the lexer
<zamith>
it's kind of big
<zamith>
I'll take a stab at it later
<zamith>
for now, the tests
<zamith>
:p
<asterite>
In this case I have a mixed feeling, because to understand the lexer specs you need to understand this new class, and the Lexer. Maybe we could have the methods of LexerObjects::String directly in the Lexer by reopening it? It would only be in the specs, so...
<zamith>
it happens to code that grows "organically"
<zamith>
hum... what is the benefit there?
<asterite>
Yes, the code grew mostly out of use cases, bugs, etc. We did design some things, like how overloads work, etc.
<zamith>
I was aiming at the naming being good enough that you didn't have to go to the test class, to read the tests
<zamith>
writing them is a different story
<zamith>
are you talking about the fact that you need to pass the lexer in?
<asterite>
If you need to write the test, in order to keep it in sync with how the tests are written, you have to first read the whole LexerObjects::String class to see if there’s a method there you can reuse
<zamith>
yes, you do
<asterite>
But “169 additions and 280 deletions” looks good :)
<zamith>
yeah
<asterite>
That means 280 lines gone and 169 added, right?
<zamith>
yes
<asterite>
Cool :)
<zamith>
but most of them are added to the lexer object file
<asterite>
Yes. Well, I think I like the idea :)
<zamith>
the actual test file is less 200 lines and I haven't gone to the end
<asterite>
It does indeed make reading and writing the specs easier
<asterite>
forget what I said earlier
<asterite>
if you need to add one more spec you are right next to other specs so you would immediately understand how to add one
<zamith>
it does have the cost of having to learn the lexer object's api
<zamith>
it's like a dsl in that sense
<zamith>
but reading is much easier
<zamith>
which I hope will make it easier for someone new to contribute
<asterite>
Definitely
<asterite>
Yes, I agree with you. If you want to continue in this direction, please go ahead :)
<zamith>
nice
<zamith>
:)
<asterite>
The “next_string_token_should_be_opening” with the hardcoded 1 there, I’m not sure about that
<asterite>
But for now it’s ok, I guess
<asterite>
The compiler’s code is about 31615 lines of code right now, and the specs are 27278
<asterite>
I think that’s pretty small :). But the more we can reduce those numbers, the better
<zamith>
the naming is up for grabs
<zamith>
please do suggest other names
<zamith>
I just got that from going through the specs
<zamith>
and so far the "abstractions" that I needed were those
<asterite>
Oh, I was talking about the hardcoded “1” there. You can have something like “#{“#{“#{… and there the opening will be 1, 2, 3…
<zamith>
is there a spec with that?
<asterite>
But ignore me, for now it’s perfect like that :)
<zamith>
ok, I'll carry on, then
<asterite>
I don’t think so :blush:
<asterite>
That’s why maybe it doesn’t matter for now, hehe
<zamith>
hahaha
<zamith>
did it based on the specs, only
bcardiff has quit [Quit: Leaving.]
<asterite>
Do you want me to merge your PR and you continue on top of that, or you want to do the whole refactor and then I merge it?
<jhass>
asterite: :) So, feel free to pull whatever you like from core_ext, or you tell me what you like and I'll open PRs ;)
bcardiff has joined #crystal-lang
<asterite>
jhass: for starters, if you didn’t show me your code maybe we would have implemented Process.run as you suggested, thus duplicating effort :-P
<asterite>
jhass: I think all of the code in core_ext, and thread, is very good and welcome. So please submit PR for these (individually)… but add specs for them ;)
<jhass>
well, there are some questions, like do we want String#count and String#delete with the ruby behavior?
<jhass>
Promise I never even compiled :D
<jhass>
the openssl stuff, dunno, I'm really no crypto guy and just made it work
<jhass>
openssl/io.select: I'm not sure if I completely got the IO design of crystal yet
<asterite>
If it works its better than nothing and we can always improve it later
<asterite>
String#count and String#delete are fine, I guess. We can also have a variant that accepts a block and yields chars, so you can decide which chars apply
<jhass>
CheckingMutex I wouldn't want to add, but if anything replace Mutex with it
<asterite>
Ok. I’ll take a look case by case and pull, then :)
<jhass>
what do you think about my Array#to_h hack? :P
<asterite>
hack?
<jhass>
I'm fine with adding tests and doing PRs
<jhass>
delegating to a class method with a type restriciton
<asterite>
I think that’s perfectly fine :)
<jhass>
k :)
<asterite>
It’s a way to do compile-time introspection, and if it works and we don’t need to add more features to the language, then it’s good :)
<jhass>
so, as said I'm fine with doing PRs, I'm really just like some feedback first whether you like it, what the complete design for some things should be etc. before going through the effort :)
<asterite>
Sure. I think then it’s better if I pull code from your codebase and ask you questions. It’ll be easier for both of us
<asterite>
For Array#to_h another way is to do: Hash(typeof(self[0]), typeof(self[1])).new
<asterite>
That way it can also work for Array(Array(…)) or Array of anything that responds to []
<asterite>
You can try it and see if it works :)
<jhass>
ah typof I didn't know yet
<jhass>
no overload matches 'Hash({Symbol, Int32}, {Symbol, Int32})#[]=' with types Symbol, Int32
<jhass>
I think that's actually sensible since it's a valid outcome of the method, not something that's gone wrong
<jhass>
maybe add an overload that if no timeout is given does .not_nil! ?
<asterite>
Maybe
asterite has quit [Quit: asterite]
asterite has joined #crystal-lang
asterite has quit [Client Quit]
asterite has joined #crystal-lang
<jhass>
you need a bouncer :P
<zamith>
asterite: I will add more stuff and you can merge it then
<zamith>
;)
<asterite>
zamith: great :)
<asterite>
jhass: what’s a bouncer?
<jhass>
a proxy for IRC that keeps you connected
<asterite>
Even if I close my machine?
<jhass>
psybnc and znc are the most popular ones ;)
<jhass>
yes, it should run on a server
<jhass>
to your client it's an IRC server, to the server it's a client ;)
<asterite>
I always wondered why you are always connected, and whether you sleep or not
<asterite>
I guess that’s my answer :)
<jhass>
I guess you could have an account on mine if you really wanted to, it's not the most stable one though :P
<asterite>
jhass: I don’t think it’s much of a problem for me right now, but thanks anyway :)
<jhass>
well, the advantage is that people can leave messages and be sure you'll see them. IRC is actually a kind of asynchronous medium that only transitions into realtime when all parties are actually available
<jhass>
but as you like ;)
<jhass>
I guess we could also use MemoServ
<jhass>
or !memo :D
<asterite>
the bouncer will tell me when someone talks to me even if I’m not connected? how?
<asterite>
Right now I check the irc logs almost every day, to see if there was any activity, so… :)
<jhass>
you can configure different modes
<jhass>
one is to just playback the channel history on connect
<jhass>
another one is to only playback highlights
<jhass>
with channel history I mean everything that was sent while you were disconnected
zamith_ has joined #crystal-lang
zamith_ has quit [Remote host closed the connection]
zamith has quit [Read error: Connection reset by peer]
zamith_ has joined #crystal-lang
sferik has joined #crystal-lang
jhass has quit [Quit: Bye]
jhass has joined #crystal-lang
asterite has quit [Quit: asterite]
jhass has quit [Quit: Bye]
jhass has joined #crystal-lang
asterite has joined #crystal-lang
<jhass>
mmh, I wonder whether we should have Array#+(Tuple), Tuple#+(Tuple) and Tuple#+(Array), if it's even possible that is
<asterite>
All of those returning arrays?
<asterite>
I wouldn’t use tuples as arrays, really
<asterite>
And if you do want to use them as array, you can always do array + tuple.to_a
<jhass>
Tuple#+(Tuple) would return an Tuple
<jhass>
Is Array#to_a free?
<jhass>
I'm thinking of being able to duck type with accepting Arrays and Tuples interchangeably
<asterite>
I wasn’t sure that was going to work :-P
<asterite>
I guess we could add all those methods. I don’t know how would Array#+(Tuple) be implemented, I guess you’d need to call to_a on the tuple for now
<jhass>
heh, smart
<jhass>
I think that would be fine
<jhass>
can one type restrict to any tuple actually?
<jhass>
def foo(a : Array); def foo(a : Tuple);
<asterite>
You can add them to your core_ext and I’ll later extract them (and add specs), or you can just submit pull requests, whichever you like :)
<asterite>
Yes, you can
<jhass>
cool
<jhass>
I'll see
<jhass>
I try to get IO.select into a PRable shape for now
<asterite>
Good. Did you manage to make it nilable or not depending on the timeout?
<jhass>
Not sure yet
<jhass>
currently exploring replacing the call in Process.run
<asterite>
Transform that C.select into IO.select?
<jhass>
yup
<asterite>
Good :)
<jhass>
hangs the specs currently unfortunately, so I broke something :P
<jhass>
asterite: we might need to disallow tap on structs
<jhass>
or special case it
<asterite>
Why?
<jhass>
because it's a common pattern to modify an object in a constructor method with tap
<jhass>
so def self.create; new.tap do |obj| obj.something = 3; end; end; or whatever
<asterite>
I see. I almost never use tap :-P . Mmm… but you might still want to tap and not modify the object. So I’m not sure disallowing it completely is ok
<jhass>
kay, we can leave it as a gotcha for now and in the long term maybe add a flag to them that marks them immutable and mark the copy passed by tap immutable then
<jhass>
or something like that
<asterite>
Yes, mutable structs are bug-prone :(
<asterite>
Maybe we should only have immutable structs, but in some cases they can improve performance but you have to be careful
leafybasil has quit [Remote host closed the connection]
<jhass>
>> {{'a', 'b'},{'c', 'd'}}
<CeBot>
jhass: Syntax error in eval:3: expecting token '}', not ','
asterite_ has joined #crystal-lang
asterite has quit [Ping timeout: 255 seconds]
asterite_ is now known as asterite
sferik has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]