<blassin>
I'm converting an old Crystal 0.10 I think project I had around to the newest version
<blassin>
but trying to get this hash to work is killing me
<blassin>
the idea is to have a dictionary of info about different opcodes for different versions
<blassin>
and so, for version 5 it should contain all info from version 1-4
<blassin>
that's the code iterating through the keys
<blassin>
the error shown makes me think for some reason the "illegal" NamedTuple is not being specified properly
<asterite>
blassin: don't use named tuple for that, use record
<blassin>
for the OpcodeInfoEntry?
<blassin>
I'll try
tomchapin has quit [Ping timeout: 264 seconds]
<blassin>
asterite: updated gist, similar error now with records
<blassin>
should I make the OpcountHash container a record too?
<blassin>
I've recordified everything
<blassin>
the error baffles me:
<blassin>
no overload matches 'Hash(Int32, Czm::Opcodes::IllegalOpcodeInfoEntry | Czm::Opcodes::LegalOpcodeInfoEntry).new' with type Hash(Int32, Czm::Opcodes::LegalOpcodeInfoEntry)
<FromGitter>
<kofno> https://carc.in/#/r/151y <-- shouldn't negative counts work, instead of raising an error?
<FromGitter>
<kofno> Work-around is to use a range with a -1 end.
<FromGitter>
<kofno> But based on the documentation, negative counts should work too
Philpax has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
pawnbox has joined #crystal-lang
<FromGitter>
<jwoertink> interesting... Anytime I click on those "carc.in" links, they never work. Just tried it in chrome, and looks like it's code!
<FromGitter>
<jwoertink> I've always wondered what those were
matp has quit [Remote host closed the connection]
<FromGitter>
<kofno> Actually, I may have misread the documentation on the -1 count.
<FromGitter>
<kofno> Docs say negative _index_, but don't say anything about how a negative count is handled.
<FromGitter>
<kofno> I make that mistake in Ruby too... some_array[1..-1] gets everything after the first element. Of course, I'd like to see a `rest` method for that :)
<adam12>
I guess because it's not a proper hash, but still JSON::Any, the select method isn't what I expected.
<FromGitter>
<jwoertink> agreed. Maybe a pull request to override it is in order?
<adam12>
I think it was done on purpose, imho.
<adam12>
I think you need to convert it to a hash to end the possibility of JSON traversal.
<FromGitter>
<jwoertink> I guess that would make sense. Be a bit more explicit in what you're trying to do
<adam12>
Tho JSON::Any includes Enumerable? so I dunno.
pawnbox has joined #crystal-lang
dannluciano has joined #crystal-lang
dannluciano has quit [Ping timeout: 258 seconds]
matp has joined #crystal-lang
dannluciano has joined #crystal-lang
onethirtyfive has joined #crystal-lang
dannluciano has quit [Ping timeout: 264 seconds]
Philpax has joined #crystal-lang
Philpax has quit [Ping timeout: 260 seconds]
Cidan is now known as zz_Cidan
dannluciano has joined #crystal-lang
matp has quit [Remote host closed the connection]
dannluciano has quit [Ping timeout: 240 seconds]
mark_66 has joined #crystal-lang
rolha has joined #crystal-lang
dannluciano has joined #crystal-lang
dannluciano has quit [Ping timeout: 240 seconds]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
willl has quit [Quit: Connection closed for inactivity]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox_ has joined #crystal-lang
pawnbox has quit [Ping timeout: 264 seconds]
dannluciano has joined #crystal-lang
dannluciano has quit [Ping timeout: 252 seconds]
A124 has quit [Read error: No route to host]
A124 has joined #crystal-lang
matp has joined #crystal-lang
matp has quit [Remote host closed the connection]
trapped has joined #crystal-lang
matp has joined #crystal-lang
Ven has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dannluciano has joined #crystal-lang
dannluciano has quit [Ping timeout: 244 seconds]
pawnbox_ has quit [Remote host closed the connection]
steenuil has joined #crystal-lang
dannluciano has joined #crystal-lang
pawnbox has joined #crystal-lang
kostya has joined #crystal-lang
pawnbox has quit [Ping timeout: 258 seconds]
dzv_ has quit [Ping timeout: 240 seconds]
dzv_ has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
Philpax has joined #crystal-lang
dannluciano has quit [Ping timeout: 276 seconds]
pawnbox has joined #crystal-lang
Ven has joined #crystal-lang
<BlaXpirit>
so uh are we gonna get a "docrystal" again? cuz it sure seems dead
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<RX14>
doc.cr would be nice but cr tlds are expensive
<crystal-gh>
[crystal] asterite closed pull request #3046: Added support for negating unsigned integers (master...master) https://git.io/vKHb6
<FromGitter>
<asterite> It seems that there's no way JSON::Any can be an Enumerable to handle the cases of array and hash, because it yields either one element or two... I think it's better if we made JSON::Any not be an Enumerable to avoid confusion
<crystal-gh>
[crystal] asterite pushed 4 new commits to master: https://git.io/vKpAj
<crystal-gh>
crystal/master 0c62997 Ary Borenszweig: Compiler: more refactors...
<crystal-gh>
crystal/master 11bbf9c Ary Borenszweig: Compiler: renamed `container` to `namespace` in Type
<FromGitter>
<elorest> Do you know if there’s a way to define BigInts without BigInt.new(1). Something equivalent to 123_i64, like 10000_bint
<BlaXpirit>
elorest, well, no, they are not tied to the language, just a class
<BlaXpirit>
though it's not out of the question that they may be in the future
<FromGitter>
<elorest> @blx
<FromGitter>
<elorest> @BlaXpirit thanks.
<BlaXpirit>
is there any global location to install crystal libraries into?
<RX14>
global libraries don't make much sense to me
<BlaXpirit>
well crystal doesn't make it easy to use local C libraries
<BlaXpirit>
so most of the time you end up with C libraries globally and crystal wrapper locally. easy for them to mismatch. and if it's not a widespread C library, you dont want to have it installed globally
<RX14>
what do you mean by mismatch...
<BlaXpirit>
wrapper for a new version, actual lib is old
<RX14>
well that's just unix
<RX14>
nothing much you can do
<BlaXpirit>
yes you can do - install packages globally using your package manager
<BlaXpirit>
crystal has no such option
<RX14>
how does that solve the problem?
<BlaXpirit>
package maintainer makes sure the library versions match
<FromGitter>
<sdogruyol> i also like to have global install
<RX14>
that makes no sense because you depend on the version of the wrapper
<RX14>
then you end up with a mess when every system has a different wrapper version
<FromGitter>
<sdogruyol> sometimes i wish for statically linked fat binaries
<RX14>
and thats worse than the original version because crystal wrappers will change faster than the underlying C libraries
<RX14>
dynamic libraries are versioned
<RX14>
and you can usually get old versions from your system package manager
<RX14>
global crystal libraries don't fix the problem at all
<FromGitter>
<Svenskunganka> Hey guys, I'm looking to implement a CSS preprocessor in Crystal to learn the language better. Do you know of any papers or have any pointers on how one would write an efficient parser for such a thing? I've been looking at the YAML implementation in Crystal, but it seems to be using a C implementation so I can't get a lot out of it but there was a bunch of nice things in there.
<RX14>
traditional parsers will have a lexer to convert the source code into a stream of tokens
<BlaXpirit>
Svenskunganka, check out json maybe, it's great
<RX14>
then maybe a recursive descent parser which reads the tokens and constructs a abstract syntax tree
<FromGitter>
<sdogruyol> @Svenskunganka there's a Slim like template language written in Crystal which may give you some tips https://github.com/jeromegn/slang
<BlaXpirit>
yaml - sure, it's so crazy complex that it's more sensible to use an existing one
<RX14>
BlaXpirit, json is on a different level then css preprocessor
<RX14>
depends on how complex the input langauge is
<RX14>
but you generally want a lexer to convert a string into tokens
<RX14>
then construct some datastructures out of the tokens
<RX14>
usually an AST for a traditional programming langauge compiler
<RX14>
css is a bit simpler
<RX14>
again, it depends on the complexity of the input langauge
<RX14>
crystal's own compiler has a good example of a lexer
<FromGitter>
<Svenskunganka> Oh alright, you guys mentioned some things I'll definitely look up. I know what an AST is but lexer is a bit of a gray area, but thank you guys for the links. I love that there are already so much in the crystal source that I can learn from!
<FromGitter>
<Svenskunganka> I'd like it to have support for functions and namespaces, so the Crystal lexer is probably a good resource itself
<RX14>
basically what a lexer does is turn `{ foo: "bar"}` into [OBJECT_START, KEYWORD(foo), SEPERATOR, STRING(bar), OBJECT_END]
<FromGitter>
<Svenskunganka> Oh, I thought that was an AST?
<RX14>
no, an AST is a tree with nested objects
<RX14>
this is a simple array of tokens
<FromGitter>
<Svenskunganka> OK, thank you for your help!
<RX14>
the AST of that would be Object(pairs: [Pair(key: ConstantString(foo), value: ConstantString(bar))])
<RX14>
well
<RX14>
an AST
<RX14>
you can represent it any way you like really
tomchapi_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Oliphaunte has joined #crystal-lang
<FromGitter>
<Svenskunganka> Alright looking at the Slang source I see some pointers of what you mean
<FromGitter>
<Svenskunganka> This is going to be great! :D
tomchapin has joined #crystal-lang
dannluciano has joined #crystal-lang
dannluciano has quit [Ping timeout: 276 seconds]
<crystal-gh>
[crystal] asterite pushed 3 new commits to master: https://git.io/vKh5x
<crystal-gh>
crystal/master 6967838 Ary Borenszweig: Compiler: try to invoke `finalize` in `new` if a type responds to it. Fixes #3060
<crystal-gh>
crystal/master c2ba050 Ary Borenszweig: Fixed #3045: error when redining fun with different signautre
<crystal-gh>
crystal/master a2ff203 Ary Borenszweig: Compiler: no need to store "new expansions" in Program
pawnbox has quit [Remote host closed the connection]