<vifino>
Hey jhass, if you don't mind me bugging again: What would I use to communicate between functions, threads and stuff. Basically, I need something like a pipe, but passing Crystal-native data.
havenwood has joined #crystal-lang
joneslee85 has joined #crystal-lang
joneslee85 has quit [Ping timeout: 265 seconds]
joneslee85 has joined #crystal-lang
joneslee85 has quit [Ping timeout: 246 seconds]
joneslee85 has joined #crystal-lang
havenwood has quit [Ping timeout: 256 seconds]
joneslee85 has quit [Ping timeout: 264 seconds]
joneslee85 has joined #crystal-lang
joneslee85 has quit [Ping timeout: 244 seconds]
joneslee85 has joined #crystal-lang
havenwood has joined #crystal-lang
joneslee85 has quit [Ping timeout: 240 seconds]
joneslee85 has joined #crystal-lang
joneslee85 has quit [Ping timeout: 264 seconds]
flaviu has quit [Ping timeout: 244 seconds]
joneslee85 has joined #crystal-lang
flaviu has joined #crystal-lang
joneslee85 has quit [Ping timeout: 240 seconds]
joneslee85 has joined #crystal-lang
flaviu has quit [Ping timeout: 264 seconds]
flaviu has joined #crystal-lang
joneslee85 has quit [Ping timeout: 256 seconds]
joneslee85 has joined #crystal-lang
<vifino>
Hello again. I get 'Error in ./test.cr:12: undefined method '[]=' for Hash(String, (String -> String)):Class' in the following test code: http://hastebin.com/ejayoxosim.rb
<vifino>
Anybody knows how to get around this issue?
joneslee85 has quit [Ping timeout: 260 seconds]
Locke23rus has quit [Remote host closed the connection]
joneslee85 has joined #crystal-lang
joneslee85 has quit [Ping timeout: 256 seconds]
joneslee85 has joined #crystal-lang
<willl>
vifino: the answer is in the error message, but maybe a little tricky to suss out. There is in fact no []= method on the /class/ Hash
<crystal-gh>
[crystal] yui-knk opened pull request #1017: Add test for `Range.new` (master...test/range_new) http://git.io/vm5fY
joneslee85 has quit []
Ven has joined #crystal-lang
lokulin has joined #crystal-lang
lokulin has quit [Changing host]
sardaukar has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<crystal-gh>
[crystal] yui-knk opened pull request #1018: Add `abstract def to_s_with_source` to `Crystal::Exception` (master...fix/abstruct_to_s_with_source) http://git.io/vm5uD
Ven has joined #crystal-lang
zipR4ND has joined #crystal-lang
<zipR4ND>
hello, can someone help me with this: http://carc.in/#/r/7kw i am defining getters via class macros and want to collect the output of all the defined getters in one method :children ...
<jhass>
zipR4ND: DEFINED_GETTERS is populated at runtime, you access it at compile time there
<jhass>
it's already an array, just return it?
<jhass>
oh, I think I see what you're doing
<zipR4ND>
jhass: i dont want the method names, i want the getter methods actually be called to retrieve their values
<jhass>
how about you creates a @properties hash, let the getter/setters do @properties[:{{name.id}}] and then just return @properties.values?
<jhass>
mmh, well plus casts for the return values
<zipR4ND>
jhass, this might be a solution, having all in a nice hash would be cool anyway
<jhass>
I guess you could also hack something crazy up with overriding children all the time and using previous_def
<zipR4ND>
all the children have the type (ASTNode?|Array(ASTNode?))
<zipR4ND>
i am really getting into type inference hell there
<zipR4ND>
also tried pushing procs to an array and then mapping + calling the each of the procs. works for getters but I need to cast and cast and get errors that dont make sense like: expected ... to return (ASTnode|Nil) not ASTNode? and stuff
<jhass>
do you need to compose over inheritance or could you make the child definition a single macro call?
<jhass>
taking a HashLiteral similar to json_mapping
<zipR4ND>
jhass: i don't understand? I want to be able to extend each defined ASTNode as deep as I want
<jhass>
so in B < A < ASTNode B should inherit A's child definitions
<jhass>
?
<zipR4ND>
yes please!
<jhass>
(and be able to add more on its own)
<zipR4ND>
yes
<jhass>
that makes it harder
<jhass>
well I guess the @properties approach makes it possible if you cast around accordingly
<jhass>
mmh
<jhass>
though you'd need to know all possible value types beforehand I guess :/
<zipR4ND>
a child will always be ASTNode+ or Array(ASTNode+)
<zipR4ND>
or Nil
<zipR4ND>
or Array(ASTNODE+|Nil)
<jhass>
then I got confused by your example using String I guess
<zipR4ND>
oh your right
<zipR4ND>
how did this even compile?
<zipR4ND>
i change it ..
<jhass>
well, it's an ArrayLiteral still
<jhass>
and in the other case it isn't
<jhass>
and then you actually don't pass Strings, so the type restrictions pass
joneslee85 has quit [Remote host closed the connection]
<jhass>
haha it's interpreting it as ternary
<jhass>
I'd call that a bug
<jhass>
but |Nil should work
joneslee85 has joined #crystal-lang
asterite has joined #crystal-lang
<zipR4ND>
cool, thanks jhass this is working as i wanted (even bettter through Union Types in the macro )
joneslee85 has quit [Remote host closed the connection]
joneslee85 has joined #crystal-lang
<asterite>
zipR4ND: I wouldn't program in that way, I'd use separate instance variables for each of the properties
<asterite>
I'm not sure why you need the @properties instance variable. But you are basically programming the Ruby-way: let every object be a hash, so lookups and assignments are slow :(
<jhass>
asterite: read up, we tried that initially
<jhass>
I guess we could try to implement children with @type.instance_vars.select but that results in even more casting and whatnot
<asterite>
Oh, I mean, without macros. Just regular getters and setters
<jhass>
asterite: btw you should idle here more, dzv tries to have a talk with you for days now :P
<asterite>
Yeah... :-( . The problem is that lately I have less time to be here
<jhass>
my offer to give you an account on my bouncer stays
<jhass>
that way people will ask their questions, you reply if you have time and eventually it may happen that both are around at the same time
<jhass>
if not IRC also works for many people with 6+ hours delays between the responses ;P
<asterite>
it's easier if you have a single macro entry to do all the stuff. Here I pass a hash, but you could also pass many expressions, but a hash is easier to operate in macros
<asterite>
jhass: so, how do I get started with the bouncer?
<jhass>
asterite: I asked them about that but they want it to work across inheritance
<jhass>
asterite: saw my private message?
<asterite>
Oh! Right
<asterite>
What do you mean across inheritance?
joneslee85 has quit [Remote host closed the connection]
joneslee85 has joined #crystal-lang
asterite_ has joined #crystal-lang
asterite_ has quit [Client Quit]
asterite_ has joined #crystal-lang
asterite_ has quit [Remote host closed the connection]
<crystal-gh>
[crystal] yui-knk opened pull request #1019: Fix error messages of undefined macro method exception (master...fix/macro_method) http://git.io/vmdDY
asterite_ has joined #crystal-lang
bcardiff has joined #crystal-lang
joneslee85 has quit [Remote host closed the connection]
joneslee85 has joined #crystal-lang
joneslee85 has quit [Read error: Connection reset by peer]
joneslee85 has joined #crystal-lang
joneslee85 has quit [Remote host closed the connection]
jhass has quit [Quit: and then /msg *status connect then I'm afraid]
joneslee85 has joined #crystal-lang
jhass has joined #crystal-lang
joneslee85 has quit [Read error: Connection reset by peer]
asterite_ has quit [Quit: Bye]
joneslee85 has joined #crystal-lang
joneslee85 has quit [Remote host closed the connection]
asterite_ has joined #crystal-lang
<asterite_>
foo
<jhass>
o/
joneslee85 has joined #crystal-lang
joneslee85 has quit [Remote host closed the connection]
asterite has left #crystal-lang [#crystal-lang]
asterite_ has quit [Client Quit]
asterite has joined #crystal-lang
<jhass>
asterite: a simple /nick asterite would've sufficed :P
<asterite>
Hm, right... :-P
<BlaXpirit>
> asterite@aeshna.de
<BlaXpirit>
???
<strcmp1>
yep, the germans have taken him. no hope now.
joneslee85 has joined #crystal-lang
joneslee85 has quit [Remote host closed the connection]
<jhass>
gotta achieve world domination somehow...
<asterite>
I moved to Berlin. Seems all the Crystal hype is there
<jhass>
haha, maybe a bit too plausible xD
<BlaXpirit>
can we speak seriously here?
joneslee85 has joined #crystal-lang
<jhass>
joneslee85: mind fixing your connection btw?
joneslee85 has quit [Read error: Connection reset by peer]
<asterite>
Ok. I'm using jhass's bouncer to connect to IRC now
joneslee85 has joined #crystal-lang
<jhass>
joneslee85: mind fixing your connection btw?
joneslee85 has quit [Remote host closed the connection]
joneslee85 has joined #crystal-lang
joneslee85 has quit [Remote host closed the connection]
<thor77>
http://carc.in/#/r/7n7 it complains about 15: no overload matches 'Array(String)#[]' with types Int32, (Nil | Int32) how could @@key_length be Nil?
<jhass>
you meant to use @instance_variables
<jhass>
not @@class_variables
<thor77>
uh, right
<thor77>
now it works o.O
bcardiff has joined #crystal-lang
<zipR4ND>
asterite jhass : regarding asterites last comment on slow hash lookups, is this: http://carc.in/#/r/7n8 a more efficient solution to the problem?
<jhass>
zipR4ND: check the logs, asterite gave a couple more solutions
<zipR4ND>
ah ok, sorry
<jhass>
no worries
<asterite>
zipR4ND: I think this solution is simple and efficient: http://carc.in/#/r/7n1
<zipR4ND>
asterite yes your right, i already thought of that, but i want to stay as close to the original(ruby) api as possible, porting: https://github.com/chriswailes/RLTK btw ..
<asterite>
zipR4ND: You want to make a parser generator?
<zipR4ND>
yes
<asterite>
Then I'd suggest using the run macro method, because you won't be able to do much with regular macros for this
<zipR4ND>
i have a little project and i want a dynamic language embeddet, stumbled upon this RLTK and thought it would be nice having it for crystal
<asterite>
Basically, send the grammar to an external program that will generate the program that you want
<asterite>
but doing it the Ruby way won't work, because in Ruby everything happens at runtime so it's very easy to do basically anything
<zipR4ND>
hmm, i am just dump porting the code and make the tests green
<zipR4ND>
already ported: token, lexer, cfg, and parser ..
<zipR4ND>
yeah i know, i learn alot about the difference between ruby and crystal this way
<zipR4ND>
i am not completely sure about the benefit of this .. you can define a lexer, parser, ast and create a compiler in crystal, then you compile it to binary. thought this may be nice for rapid language prototyping .
jtarchie has quit [Quit: Connection closed for inactivity]
asterite_ has quit [Remote host closed the connection]
<vifino>
willl: Oh damn. Thanks, I think coding after 1 am makes my code quality suffer :)
asterite_ has joined #crystal-lang
zipR4ND has quit [Ping timeout: 250 seconds]
asterite_ has quit [Remote host closed the connection]
NeverDie has joined #crystal-lang
bcardiff has quit [Ping timeout: 250 seconds]
nahtnam has joined #crystal-lang
asterite_ has joined #crystal-lang
zipR4ND has joined #crystal-lang
<zipR4ND>
hey jhass, asterite given the last discussions, i have an inheritance problem, because the class constants seem to get shared between types in the hierarchy: http://carc.in/#/r/7oz can you help (again :) )
<asterite>
you could declare the constants in a `macro inherited` section. However, I'm not sure why you need all that children info at runtime
<zipR4ND>
hmm, right ..
<zipR4ND>
what i want is the described api to work
sardaukar has left #crystal-lang [#crystal-lang]
miah_ is now known as miah
sergey-kucher has joined #crystal-lang
sergey-kucher has quit [Client Quit]
sergey-kucher has joined #crystal-lang
shama has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<asterite>
I think using Ruby's syntax isn't always good... I don't think people should port Ruby libs to Crystal by just copy pasting :(
<strcmp1>
its fine for getting the bare minimum to work
<strcmp1>
imo :)
asterite_ has quit [Remote host closed the connection]
<dzv>
could we have a ruby parser? so that require "foo" searches for "foo.cr" first then "foo.rb" second and tries to parse in a ruby compatible mode? that way gems could be easier to import, especially if only a few classes need type information added.
<jhass>
no, crystal started out as trying to compile ruby code. There are things you just cannot do
<vifino>
Block overloads don't work? :(
<strcmp1>
dzv, it was suggested before to add some sort of subset of ruby that could be compiled as crystal but iirc it was rejected becos crystal wants to be its own language, and doing that would be kinda restrictive
<dzv>
some of my ruby code runs without modification if simple things are provided like attr_*
<vifino>
Wait, okaaay. So some block overloads work, some not.
<vifino>
Weird.
<dzv>
right now library support is very poor. making use of the many existing libraries or having a pathway to enhance existing libraries without rewriting everything would make using crystal a lot easier
asterite_ has joined #crystal-lang
asterite_ has quit [Remote host closed the connection]
asterite_ has joined #crystal-lang
asterite_ has quit [Remote host closed the connection]
asterite_ has joined #crystal-lang
asterite_ has quit [Remote host closed the connection]
asterite_ has joined #crystal-lang
sergey-kucher has quit [Ping timeout: 246 seconds]
asterite_ has quit [Remote host closed the connection]
<dzv>
is there a use case for else in a method definition? it seems superfluous. http://carc.in/#/r/7pd
<strcmp1>
if an exception wasn't raised, yes.
<strcmp1>
in your example, no, its useless.
<dzv>
where is it useful?
<strcmp1>
when an exception could or could not be raised, and you want to do something else when nothing is raised.
<dzv>
i removed the raise and the result of the 2 functions is the same
<dzv>
still seems useless
<dzv>
the main body runs when nothing is raised. else seems like another part of the main body but seperate for what reason?
zipR4ND has quit [Ping timeout: 244 seconds]
<strcmp1>
well, yes youre right, you could put the 'else' block of code within the main body too.
asterite_ has joined #crystal-lang
asterite_ has quit [Remote host closed the connection]
asterite_ has joined #crystal-lang
bcardiff has joined #crystal-lang
bcardiff has quit [Quit: bcardiff]
bcardiff has joined #crystal-lang
asterite_ has quit []
BlaXpirit has quit [Quit: Konversation]
<nahtnam>
Is there an ide for crystal?
<wmoxam>
nahtnam: there are editor plugins
<nahtnam>
wmoxam: Ah, kk
<wmoxam>
Atom, Vim, maybe others
<nahtnam>
Was about to ask about atom
<nahtnam>
Ill look it up
<nahtnam>
thanks
<wmoxam>
np
<crystal-gh>
[crystal] jbbarth opened pull request #1020: Fix Regex 'm' modifier mistakenly mapped to PCRE_DOTALL (master...bugfix/regex-multiple-newlines) http://git.io/vmART
bcardiff has quit [Quit: bcardiff]
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
havenwood has quit [Ping timeout: 244 seconds]
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: http://git.io/vmADd