<jemc>
But I have some cases in a more complicated program that seem to recurse indefinitely
<jemc>
Is this a known issue? I didn't find a bug ticket about it, but maybe it's an unspoken knowledge?
<jemc>
If it is not a known limitation, I can try to isolate a minimal repro and file a ticket
akaiiro has quit [Remote host closed the connection]
<FromGitter>
<Sija> @jemc please do
<jemc>
okay, thanks for confirming - will spend some time on that minimal repro
jemc has quit [Ping timeout: 244 seconds]
akaiiro has joined #crystal-lang
jemc has joined #crystal-lang
DTZUZO has joined #crystal-lang
akaiiro has quit [Ping timeout: 268 seconds]
DTZUZO has quit [Ping timeout: 250 seconds]
Renich_ has joined #crystal-lang
Renich has quit [Ping timeout: 250 seconds]
Renich_ is now known as Renich
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 246 seconds]
jemc has quit [Quit: WeeChat 2.2]
jemc has joined #crystal-lang
robacarp has quit [Ping timeout: 272 seconds]
Renich has quit [Remote host closed the connection]
Renich has joined #crystal-lang
robacarp has joined #crystal-lang
mrush has joined #crystal-lang
mrush has left #crystal-lang [#crystal-lang]
junland has quit [Quit: Disconnected.]
junland has joined #crystal-lang
<FromGitter>
<girng> why don't i need to do array.delete! value????
<FromGitter>
<girng> i was reading up about exclamation marks in ruby, (but i'm not sure if they mean the same crystal). but i read basically they are used if you want to modify that object itself, not the return value? and if you do array.delete value, it actually modifies the array itself. or am i missing something?
<FromGitter>
<Blacksmoke16> sounds about right
<FromGitter>
<girng> i mean tbh, i'm not complaining cause i mean array.delete value works just fine, and the array itself is modified. i was just thinking well, why don't i need to use array.delete! lol
<FromGitter>
<codenoid> hi
<FromGitter>
<codenoid> how to get current directory name in crystal
<FromGitter>
<codenoid> `File.basename(__DIR__)`
<FromGitter>
<anamba> `Dir.current`?
<FromGitter>
<codenoid> thankyou @anamba
<FromGitter>
<anamba> `File.basename(__DIR__)` is a little different, but either one could be what you need depending on the situation
<FromGitter>
<codenoid> okay, but i already commit my code with File.basename(__DIR__)
<FromGitter>
<codenoid> what, no, i mean current directory name
<FromGitter>
<codenoid> not full path
<FromGitter>
<codenoid> Dir.current is full path
<FromGitter>
<anamba> ok, you can call basename on it then
<FromGitter>
<anamba> are recursive types not recommended? thought i saw that somewhere. having some trouble with an alias of the form `alias Type = Int32 | String | Array(Type)` (simplified). i get a `can't cast Array(Int32) to Neo4j::Type`
<FromGitter>
<anamba> the casting was to try to avoid this one: `instance variable '@value' of Hash::Entry(String | Symbol, Neo4j::Type) must be Neo4j::Type, not Array(Int32)`
<FromGitter>
<anamba> i guess it's more of a general union type question. this kind of thing too, it seems like it should match, right? `no overload matches 'Array(Tuple(String, Hash(String | Symbol, Neo4j::Type)))#<<' with type Tuple(String, Hash(String, Neo4j::Type))` i always end up having to build a new hash to make this work.
<FromGitter>
<codenoid> *DIR* is static value that collect value at compile time
jemc has quit [Ping timeout: 246 seconds]
DTZUZU has quit [Ping timeout: 268 seconds]
DTZUZU has joined #crystal-lang
ashirase has quit [Ping timeout: 268 seconds]
ashirase has joined #crystal-lang
<FromGitter>
<proyb6> When can we participate in Crystal beta testing with HTTP/2? I find its a good time to allow us helping in the testing and file issue early
shmibs has quit [Quit: leaving =o]
<FromGitter>
<proyb6> @asterite Awesome! 'a'.ord produce the exact codepoint
woodruffw has quit [Ping timeout: 244 seconds]
shmibs has joined #crystal-lang
woodruffw has joined #crystal-lang
<FromGitter>
<vladfaust> @RX14 having plans on removing annotations? I mean, we were discussing their superiority against dynamic constants. If annotations are removed, there is no way to store data in compilation time π
<FromGitter>
<vladfaust> Ary calmed me down
<FromGitter>
<j8r> plan to remove inheritance, namedtuple, symbol, `[] of`/`{} of` syntax, `JSON.mapping`, `YAML.mapping`? :trollface:
<FromGitter>
<vladfaust> Namedtuples aren't that bad
<FromGitter>
<vladfaust> They-re good for inline code
<FromGitter>
<vladfaust> Others are confusing, indeed
<FromGitter>
<vladfaust> Yeah, I wonder if Crystal stdlib is going to be splitted
jemc has joined #crystal-lang
<FromGitter>
<alehander42> what are annotations?
<FromGitter>
<alehander42> something like tags for each method?
<FromGitter>
<vladfaust> Yep, they're ugly but powerful
<FromGitter>
<straight-shoota> @j8r Inheritance is useful for modelling similar concepts which only differ in specific behaviour but form a logical family of types which lots of shared behaviour. You could use composition for that. And you would have to in a non-OOP language. But OOP offers a better mechanic for this, which reduces a lot of friction. β A good example is the hierarchy of error classes. `Exception` is the base type
<FromGitter>
... and defines general behaviour of an exception. Some libraries define subtypes that inherit from `Exception` and implement some specific additions to the general interface (such as storing additional data about the error). β β Obviously, inheritance is not always a good choice. And in fact, sometimes developers have overused ... [https://gitter.im/crystal-lang/crystal?at=5c09349a28907a3c7bd98183]
<FromGitter>
<vladfaust> Good read, @straight-shoota, thanks
<FromGitter>
<kinxer> @vladfaust Annotations == Type Annotations?
<RX14>
no
<RX14>
@[Foo] annotations
<FromGitter>
<j8r> @straight-shoota Back to crystal, this force to use Classes where Structs are would fit perfectly (or I'm dumb, can't use inheritance in Structs). This yield to less performance, more memory consumption, more unpredictability
<FromGitter>
<straight-shoota> structs can use inheritance
<FromGitter>
<straight-shoota> you can only inherit from abstract structs, though
<FromGitter>
<straight-shoota> And even if inheritance was only possible with classes, noone would force you to use it if you could achieve a better result with compositing structs
<FromGitter>
<j8r> yeah right, I was confusing with other langs
<FromGitter>
<j8r> Crystal struct are a bit special comparing to C, Go and Rust. They feels more like classes
<jokke>
do you have workflows to create releases in CIs for shards?
<FromGitter>
<j8r> who?
<jokke>
why isn't there a possibility to pass structs (or any value) by reference?
<jokke>
i like this about rust
<FromGitter>
<alehander42> crystal structs sound like c# structs to me
<jokke>
lot less for the the gc to do
<FromGitter>
<alehander42> symbols vs enums is interesting
<jokke>
i think of symbols like a huge global enum :D
<FromGitter>
<j8r> jokke: good question. You can still pass pointers by reference, like `pointerof(MyStruct)`
<jokke>
yeah but there's no safety like in rust
<jokke>
rust tells you the reference will be cleaned up if you try passing it to something which will continue using it after it leaves scope
<jokke>
don't get me wrong, i'm not a rust fanboy. i think it has great features like the above, but it's super verbose compared to crystal and usually just gets in my way.
hexreel has joined #crystal-lang
Renich_ has joined #crystal-lang
Renich has quit [Ping timeout: 244 seconds]
Renich_ is now known as Renich
<FromGitter>
<proyb6> It's the first time I heard about jq
<FromGitter>
<j8r> @proyb6 for your comment, there is still room for improvement for JSON::PullParser
<FromGitter>
<j8r> I'm estimating to 10~25%
<FromGitter>
<proyb6> Great @j8r I think a benchmark on deep comparison and large amount of JSON data could be useful indicator for your shards as well
<FromGitter>
<j8r> Sadly, that's not currently my priority but I'll send a PR in the future π
<FromGitter>
<j8r> *to improve the stdlib's `JSON`
Renich_ has joined #crystal-lang
Renich has quit [Ping timeout: 250 seconds]
Renich_ is now known as Renich
jemc has quit [Ping timeout: 268 seconds]
akaiiro has joined #crystal-lang
<FromGitter>
<proyb6> π
jemc has joined #crystal-lang
<FromGitter>
<j8r> but this doesn't stop to make benchmarks, I've already done some for small data
<RX14>
JSON right now has the right structure, the rest is microoptimizations
<RX14>
and thats a good place to be in
<RX14>
s/structure/design
<FromGitter>
<j8r> Not the more optimized
<FromGitter>
<j8r> I've experienced a design with no Token class, directly returning the value
<FromGitter>
<j8r> This yield to less allocations
<FromGitter>
<j8r> and to replace the `on_key`, we can use `case/when`
<FromGitter>
<j8r> the Builder is even more performant: it creates sub builder instead of one Builder keeping track of the structure
<FromGitter>
<mhart> Hi all! A question about cross-compiling: if I do `crystal build --cross-compile` on a machine that has OpenSSL >= 1.1.0 (or >= 1.0.2), then I can't do the linking step on a machine that does not meet these OpenSSL requirements. So instead of the target being `x86_64-unknown-linux-gnu` it's technically really more accurately `x86_64-unknown-linux-gnu w/ openssl >= 1.1.0`. Digging around I'm guessing it's these
<FromGitter>
<mhart> My question is βΒ what's the least hackiest way to specify the openssl version you want to target when doing a `crystal build --cross-compile`?
<RX14>
@mhart the best was is to edit the openssl.cr file and fix it manually, and hope you dont have to cross-compile often :P
<RX14>
@j8r i meant the JSON api design, `on_key` is inlined remember so compiles to the same as `case`
<FromGitter>
<mhart> @FromIRC yeah, I want to avoid that βΒ it would be fine if it were just for me, but I'm outlining steps to do this for others
<FromGitter>
<mhart> More specifically, I'm outlining steps for how ppl can compile for the AWS Lambda env
<FromGitter>
<mhart> Which *doesn't* have OpenSSL 1.0.2
<FromGitter>
<mhart> So I don't want to tell everyone to compile their own crystal
<FromGitter>
<mhart> On my Mac I've had success with `PKG_CONFIG_PATH='' crystal build ...`
<FromGitter>
<mhart> Because then `pkg-config` just fails to find OpenSSL βΒ but that feels very brittle βΒ I'd prefer something a little more robust
<FromGitter>
<mhart> Is that something that has precedence elsewhere in the crystal codebase? The ability to override certain preprocessor/macro args at build time?
<FromGitter>
<j8r> RX14 true. the raw handling would change a bit however, not a big deal
<FromGitter>
<j8r> yeah the API won't change at 90%
<RX14>
@mhart perhaps copy old openssl's pkg-config file
<RX14>
and put it in a dir and point PKG_CONFIG_PATH at that
<FromGitter>
<kinxer> Can a heredoc be used as a constant?
<FromGitter>
<mhart> RX14 yeah, that's a good idea βΒ haven't looked into how tricky that is βΒ will try
<RX14>
shouldnt be too hard
<FromGitter>
<j8r> should I use tabs or spaces?
<RX14>
spaces
<RX14>
probably
<RX14>
the tabs is just for rules i think
<Yxhuvud>
Use whatever is used in the file already
<Yxhuvud>
but it seems to be an ugly mix of them :X
<FromGitter>
<j8r> ok, pushed a commit with spaces
<RX14>
Yxhuvud, makefiles need tabs for indenting rules
<RX14>
but the rest can be spaces
<FromGitter>
<j8r> Best idea everβ’
<FromGitter>
<j8r> use different invisible characters for semantic
<RX14>
yep
rohitpaulk has joined #crystal-lang
<FromGitter>
<straight-shoota> But that's an trap literally everyone writing Makefiles has fallen
<FromGitter>
<straight-shoota> I'd excuse it as an initiation ritual :D
<FromGitter>
<j8r> I don't know why we are still using make
<FromGitter>
<j8r> nowadays there are plenty of other alternatives
<FromGitter>
<blakexcosta> I'm relatively new to this language, but I'm interested in helping. Does anyone know where would be a good place start? Or anyone that would be willing to work/learn together?
gangstacat has quit [Quit: Δis!]
<FromGitter>
<straight-shoota> @j8r Because it's well known and ubiquitous
<FromGitter>
<straight-shoota> @blakexcosta Great. We're happy for everyone joining =)
<FromGitter>
<ilanusse> If you'd like to look at a small project to see what actual code looks like, you can look at a shard I made: https://github.com/ilanusse/praetorian
<FromGitter>
<ilanusse> It's not the best code in the work but it gives you an idea of what Crystal can look like
<FromGitter>
<straight-shoota> If you want to contribute, it's a good place to start with the standard library. Generally, you might take look at newcomer issues: https://github.com/crystal-lang/crystal/labels/community%3Anewcomer β However, the only ones currently tagged and still open are about OpenSSL. Not sure if that matches your interest.
<FromGitter>
<j8r> @straight-shoota not sure about well-kown. Known yes, but very few people know how to properly do a Makefile right
<FromGitter>
<ilanusse> @blakexcosta My current project is making a full authentication solution for Amber and Lucky, which are the biggest frameworks on Crystal rn, if it interests you, let me know
<FromGitter>
<blakexcosta> @straight-shoota @ilanusse Thank you guys! that's exceptionally helpful. β β @ilanusse code examples are always exceptionally helpful. After I finish plowing through the docs, I'll take a look. β β @straight-shoota I'm happy to tackle whatever is available in the open lib :) [https://gitter.im/crystal-lang/crystal?at=5c09666480986419d54d140b]
<FromGitter>
<mhart> Question for those in the know β I'm going to statically link in libevent to my crystal binary βΒ would it be better to use libevent 2.1.8 or 2.0.22? It seems to work with 2.1.8, and as that's the latest stable I'm tempted to prefer it, but there might be some feature introduced in 2.1 that breaks some aspect of crystal I haven't run into yet. Anyone have any opinions on this?
Renich_ has joined #crystal-lang
Renich has quit [Ping timeout: 246 seconds]
Renich_ has quit [Read error: Connection reset by peer]
<FromGitter>
<j8r> @Blacksmoke16 The Crystal cake is a lie. I hope not
<FromGitter>
<kinxer> @j8r Thanks, but I think we're actually trying to find a play on "Rake", right?
<FromGitter>
<kinxer> @vladfaust Where I grew up it was more often found as part of small, thin stones, so I'm gonna have to disagree. :P
<coderobe>
greenbigfrog: more like the other way around, really
<coderobe>
any-font-data-to-arbitrarily-sized-bitmap or something magical like that :P
<FromGitter>
<girng> @blakexcosta welcome!! check docs (https://crystal-lang.org/api) and fiddle around in the crystal playground (https://play.crystal-lang.org/). that's what i did when i first started. and ofc, you can ask questions on gitter, reddit, stack overflow
Renich has quit [Remote host closed the connection]
daemonwrangler has quit [Ping timeout: 246 seconds]
<FromGitter>
<vladfaust> But I guess I've lots of duplication...
<FromGitter>
<vladfaust> Sorry for shitposting. This is actually good, that manual allocation, allows to separate `self.new` from `initialize`
<FromGitter>
<straight-shoota> @vladfaust No, it's not about recursion
<FromGitter>
<vladfaust> Care to give an explanation, @straight-shoota ?
<FromGitter>
<elorest> Is there a better way to work with bits in crystal? https://carc.in/#/r/5pmg β β In this example I'm trying to pull 3 values out of 40 bits.
<FromGitter>
<elorest> <oprypin> this seems like the sort of question you would have the answer too.
<FromGitter>
<straight-shoota> @vladfaust visibility of `new` with pull parser argument
<FromGitter>
<vladfaust> Ah, okay
<FromGitter>
<straight-shoota> it should be defined directly on the included type
<FromGitter>
<vladfaust> As it's being a part of the module
<FromGitter>
<vladfaust> If so, why need to wrap it with `macro included; self.new ...` then?
<FromGitter>
<vladfaust> Why not just replacing `def initialize(*, __pull_for_json_serializable pull : ::JSON::PullParser)` with `def initialize(pull : ::JSON::PullParser)`? β β I experimented and found out that in this case sometimes a nested object doesn't have `def initialize(pull : ::JSON::PullParser)` yet
<oprypin>
elorest, nah this seems fine. just don't write out that `4294967295` manually. if you wanna be really cutesy, you could write a macro to generate these methods based on provided sizes and names
<FromGitter>
<blakexcosta> @girng thank you! I appreciate the advice
<oprypin>
elorest, lol seems like macros can work only with int32, so womp womp
<FromGitter>
<elorest> <oprypin> β β > @elorest, nah this seems fine. just don't write out that 4294967295 manually. if you wanna be really cutesy, you could write a macro to generate these methods based on provided sizes and names β β I can think of a few ways to do this with pretty much the same method. I was just hoping there was a different way to handle bits like bitfields in C or something. In this example I could fit
<FromGitter>
<elorest> I was looking at it but also found this odd. ` β β > Bits externally represented as Bools are stored internally as UInt32s. The total number of bits stored is set at creation and is immutable
<FromGitter>
<elorest> Are there integer types in crystal smaller than uint8?
<oprypin>
no
<FromGitter>
<elorest> Afraid of that. I could have used a slice to break them up in that case though.
jemc has joined #crystal-lang
<FromGitter>
<elorest> Still could for the most part though.
<FromGitter>
<elorest> Thanks. That's handy to know. I'm leaning toward just writing it in C and populating a struct that I use c bindings to move over.
<FromGitter>
<elorest> It feels less wrong using pointers in C lol