ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.34.0 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
rocx has quit [Quit: πŸ‘ developers πŸ‘ developers πŸ‘ developers πŸ‘ developers πŸ‘ developers]
<FromGitter> <asterite> I still think having a distinct case! is the best solution. You check exhaustiveness when you care about it and people don't get annoyed because exhaustiveness is checked when it doesn't make sense
<FromGitter> <asterite> no superfluous else and no superfluous raise
<FromGitter> <asterite> it's also not a breaking change because it's something new
<FromGitter> <asterite> but was rejected because bang
<FromGitter> <tenebrousedge> I thought `case!` was fine
rocx has joined #crystal-lang
<FromGitter> <Blacksmoke16> or another solution specific to resolving types
v2px__ has joined #crystal-lang
straight-shoota has quit [Ping timeout: 272 seconds]
v2px__ has quit [Read error: Connection reset by peer]
deavmi has quit [Ping timeout: 256 seconds]
deavmi has joined #crystal-lang
rocx has quit [Read error: Connection reset by peer]
rocx1 has joined #crystal-lang
rocx1 has quit [Client Quit]
rocx has joined #crystal-lang
rocx has quit [Ping timeout: 260 seconds]
_whitelogger has joined #crystal-lang
_ht has joined #crystal-lang
zorp has joined #crystal-lang
sagax has joined #crystal-lang
straight-shoota has joined #crystal-lang
gangstacat has quit [Ping timeout: 244 seconds]
rocx has joined #crystal-lang
<jhass> I wish I understood more about LLVM IR :/
<jhass> hitting a whole class of codegen bugs
gangstacat has joined #crystal-lang
<FromGitter> <j8r> I thought of the opposite. ⏎ Generally, trailing `!` is for unsafe and/or potentially more dangerous method compared to the regular one
<FromGitter> <tenebrousedge> yes, that's why it's appropriate. `case!` can throw errors, `case` cannot
<FromGitter> <j8r> like `.to_i32!`, `getter!`, `map!`
<FromGitter> <j8r> I don't think so
<FromGitter> <j8r> exhaustive case is safer
<FromGitter> <j8r> because it ensures that all cases are handled
<FromGitter> <tenebrousedge> but it can throw errors, which is not necessarily expected of a basic language construct
<FromGitter> <j8r> I don't know what people expect by using Crystal.
<FromGitter> <j8r> Some wants more safety, coming from Ruby, other just perf
<straight-shoota> IMO non-exhaustive case is the plain standard behaviour, exhaustive case is a more advanced feature on top of that
<FromGitter> <tenebrousedge> it's like if `if` could raise an exception. The expectation is that it works the same as in every other language. Adding additional behavior which can potentially cause your program not to compile is unexpected
<FromGitter> <tenebrousedge> what other languages offer an exhaustive `case`? Swift, Typescript...?
<FromGitter> <j8r> Swift for enums
<FromGitter> <j8r> > Switch Statements Must Be Exhaustive ⏎ ⏎ In Swift, every possible value of the control expression’s type must match the value of at least one pattern of a case. When this simply isn’t feasible (for example, when the control expression’s type is Int), you can include a default case to satisfy the requirement.
<FromGitter> <j8r> Unexpected or not depend of the user background
<FromGitter> <j8r> for instance that`if @ivar.is_a? String` does not restrict the type is also unexpected, but we learn
<FromGitter> <tenebrousedge> the background of the history of programming languages is that (correct me if I am wrong) there are precisely three of them, including Crystal, since the invention of `switch` in ALGOL, that have an exhaustive case
<FromGitter> <tenebrousedge> (btw this is an interesting history of `switch` in ALGOL: https://eev.ee/blog/2016/09/18/the-curious-case-of-the-switch-statement/ )
<straight-shoota> Lisp's ccase and ecase seem to raise at runtime if no clause matches. That's not exactly the same as our exhaustive case, but similar
<FromGitter> <j8r> Personally I don't mind much adding a `else` at the end. The fact that it can have a `nil` branch is more explicit
<FromGitter> <j8r> As I said before, may be the time for a survey πŸ˜‰
<straight-shoota> I argued for the else being not a big deal and more explicit
hightower2 has joined #crystal-lang
<hightower2> Hey maybe some llvm help... I am trying to compile a prerequisite for some crystal project, and it fails with: undefined reference to clang::PPConditionalDirectiveRecord:: and then 2 functions in it: findConditionalDirectiveRegionLoc , and rangeIntersectsConditionalDirective
<hightower2> Based on ideas from the web, I tried putting -clangEdit last, downgrading to llvm 6.0, and/or rebuilding libclangEdit.a to solve a possible symbol versioning issue. Still, error is the same
<hightower2> From looking into clangEdit's symbols with `nm`, I think the issue is the lib has the function return type and argument type without the `clang::` prefix/namespace (so it gets saved into symbol versioning without it), while from the error message it is visible it is trying with the `clang::` prefix. Can that be the reason? And if yes, how to fix?
<jhass> what are you compiling?
<sorcus> jhass: You don't understand LLVM IR or how Crystal transform yourself code to LLVM IR?
<jhass> both!
<jhass> I'm staring at the output, I see what's wrong but I can't come up with how it would be correct and where in crystal to fix it
<sorcus> "both!" - :-D X-)
<hightower2> jhass, I'm trying to get bindgen compile again, in an effort to update qt5 bindings.
<sorcus> jhass: LLVM IR shouldn't be so hard for understanding, but i don't understand how does it transform code too X-)
<FromGitter> <j8r> what is "version yanking"?
<jhass> sorcus: for example I have this bug https://carc.in/#/r/90n0, the prelude free LLVM IR to that is https://p.jhass.eu/7x.ll
<jhass> so I see it mismatches the "->" type to the function pointer type
<jhass> but no idea how to do that correctly or where that logic is in crystal
<FromGitter> <j8r> I don't really understand the issue about version yanking, why having a local db is not possible?
<FromGitter> <j8r> (sqlite or json or whatever)
<jhass> j8r: yanking is for revoking a released version. For example if it distributed malicious code
<FromGitter> <j8r> who will consider it "bad"?
<FromGitter> <j8r> the code owner, or shards owners?
<sorcus> jhass: jhass maybe @asterite know? X-)
<jhass> j8r: anybody that would normally be able to release it, given shards decentral design. In a central design there could be the central repository maintainers as an additional instance
<FromGitter> <j8r> ha ok I see
<FromGitter> <j8r> thanks
<jhass> it's not limited to malicious code, that's just the extreme example. If you accidentially released a broken version it can also be useful to force people to update from it
<FromGitter> <bararchy> Hi everyone, Yesterday I told you about our new project https://github.com/NeuraLegion/broken_crystals which is a vulnerable web application written in crystal, it's end goal is to show common pitfalls and security issues that might happen to every webdev at somepoint. ⏎ ⏎ We got some momentum and a few PRs and it's now broader in scope. If anyone has an idea on a vulnerability or scenario you wish to
<FromGitter> ... see, to be shay and jump on and let us know! ⏎ ⏎ First pre-view version is available as a docker container already :) [https://gitter.im/crystal-lang/crystal?at=5eb2cf077975db7ebfe9aaca]
<sorcus> jhass: https://github.com/crystal-lang/crystal/blob/master/src/llvm/module.cr#L76 - i think this code produce that error.
<FromGitter> <j8r> I have seen we can add notes to commits
<FromGitter> <j8r> But it won't be portable :(
<jhass> sorcus: no no, that's just triggering the validation error after it's build :)
<FromGitter> <kinxer> :O The Mirror's Edge kernel? :P
<FromGitter> <Blacksmoke16> @bararchy maybe document that vulnerabilities present/solutoins? Like in the wiki or something
<FromGitter> <Blacksmoke16> solutions*
<FromGitter> <j8r> @kinxer haha
<sorcus> Blacksmoke16 :thumbs_up:
<jhass> sorcus: https://github.com/crystal-lang/crystal/blob/master/src/compiler/crystal/codegen/codegen.cr#L507 is inserting the wrong code here, whether it should do something else or whatever populates context.vars[node_exp.name].pointer... no idea :)
<FromGitter> <bararchy> @Blacksmoke16 100% :) we will be working on that sooner then later
<FromGitter> <Blacksmoke16> πŸ‘
<sorcus> jhass: It's reproduced on all LLVM versions?
<jhass> I'm on 10.0, so it doesn't really matter IMO...
<sorcus> Blacksmoke16: `solutoins` - sounds like another bitcoin fork :-D :-D :-D
<jhass> there's a whole class of bugs here, I could show you a couple more easily :P
straight-shoota has quit [Ping timeout: 258 seconds]
<sorcus> jhass: Oh, this is so hard for me to understanding X-) :-D
<sorcus> jhass: And another limitation for is a language (english). So it double hard for me. :-D
<sorcus> jhass: But that's still interesting.
HumanGeek has joined #crystal-lang
Human_G33k has quit [Ping timeout: 272 seconds]
<jhass> hightower2: yeah sorry, too deep of a rabbit hole. I managed to fix it up enough for the make to run something reasonable on macos but then I'm just getting some error: no template named 'index_sequence' in namespace 'std' fun
<hightower2> jhass ah yes, found that error too... :)
<hightower2> although that one seemed like it could be fixed since it just seems related to the namespace, although I didn't look into what the solution would actually be
<hightower2> how did you get past the undefined reference? or it just worked in your case?
<hightower2> I mean (for the two symbols I originally mentioned)
<jhass> maybe I didn't even get far enough
<jhass> I got errors about some binary missing in the clang directory so I focused on that
<hightower2> ok, thanks for checking
<jhass> and got stuck with the compilation errors there
<hightower2> too bad it's in such a sorry state, I was expecting I could re-use all the old versions (llvm 6, crystal 0.25/0.27), reproduce a good build, and then just work from there upgrading versions and solving issues
<jhass> it's weird given the last commit is from early februrary
<hightower2> yes but I think that were just contributions from folks who did have it working, but the versions they used are unknown
<hightower2> I also checked the forks, 2 or 3 forks have some new/updated code, but not targetting this issue specifically
<jhass> btw if you haven't seen, https://github.com/crystal-lang/clang.cr is basically the same approach, just also not maintained and I think bindgen advanced a bit further
<jhass> oh and there's https://github.com/crystal-lang/crystal_lib but I forgot what approach it was using
<jhass> oh, it's just depending on clang.cr, kinda makes sense
<hightower2> jhass, ah yes, though my best bet was to try with something that was already supposed to work, before I manage to figure out how it works.. someone in llvm suggested I add --no-demangle to ldflags. This did result in the error being different. Now trying to determine if it failed earlier or later with this.
<hightower2> jhass, ah actually, I thought the symbol was in -lclangEdit... someone suggested I add -lclangLex, and this seems to have solved the particular issue... but some other errors show up now. Looking into them.
<FromGitter> <watzon> Did we ever make it anywhere on an `enum_for` type of macro/method for Crystal?
<FromGitter> <kinxer> What would that macro/method do?
<FromGitter> <watzon> Really just a more efficient way to generate an enumerable from a method that normally takes a block, like `#each`. Ideally lazily.
<FromGitter> <watzon> It's pretty commonly used in Ruby and I know there has been discussion about adding something similar to Crystal
<jhass> Enumerator < Enumberable but not vice versa
<jhass> so in crystal it probably would need to have been called iter_for
<FromGitter> <watzon> Yeah probably
<jhass> also more effecient for the coder, not more performant :P
<FromGitter> <watzon> Well I meant more efficient than trying to do something like it yourself. It's pretty easy to make a macro that takes a method like `#each`, allocates an array, and then adds everything in `#each` to the array, but that's not very efficient at all because it's not lazy.
<FromGitter> <watzon> Heh, not efficient because it's not lazy. Only in programming.
<jhass> an generic Iterator/Enumerator implementation necessarily needs to use stack context switching (fibers), hence it will never be as fast as a hand written iterator that can reimplement the algorithm in an interruptable manner with class level state
<FromGitter> <watzon> Of course not, but it could be a lot more efficient than the other method I described. I just don't know if something like that is possible with a macro currently.
<jhass> you don't even need a macro
<jhass> only if you want to support the enum_for API literally
<jhass> but not to implement the generic Enumerator
<FromGitter> <watzon> That's true
<FromGitter> <watzon> A generic enumerator would be nice to have
<FromGitter> <tenebrousedge> I support this idea
<jhass> have fun https://carc.in/#/r/90p1
<FromGitter> <tenebrousedge> πŸ‘€
straight-shoota has joined #crystal-lang
<FromGitter> <tenebrousedge> that's pretty cool
<jhass> and slow compared to def next; @n < 3 ? @n += 1 : stop; end
<hightower2> Hey jhass , got bindgen compiled... first issue: the missing symbol was not in lclangEdit, but in lclangLex. But when it didn't work I tried using clang/llvm packages from llvm.org which only got me in trouble, I should have stayed with OS-supplied packages where everything matches/is compatible. So bottom line, it compiled with just adding -lclangLex to LIBS in bindgen/clang/Makefile
<hightower2> (and I used clang/llvm 6.0 from debian packages)
zorp has quit [Read error: Connection reset by peer]
zorp has joined #crystal-lang
<jhass> yeah I guess either my LLVM is too new or the macos system installed and homebrew installed one get into conflicts with each other
<hightower2> github user lbguilherme seems to have done some patches for macos (and patches in general)
<hightower2> in his fork
<jhass> welp I have my own binding generator to care for :D
<jhass> was just procastrinating from that
<hightower2> :)
<raz> since you guys seem to dabble with LLVM. just curious, are there any low'ish hanging fruits left in terms of compile speed?
<raz> i'm quite happy with it, but wouldn't mind a couple millis less in those interactive test-cycles (esp. when working on webby stuff)
<jhass> I don't really think so. most time is spent in LLVM codegen (LLVM IR -> native code), so the only real vectors here are a) generate less LLVM-IR b) try to find stricter module boundaries to improve caching of modules. Crystal has a couple of language features that make both hard
<raz> got it, makes sense.
<raz> i know very little about it, e.g. not even if it does incremental compilation yet
<raz> (perhaps that's what these Dwarf files are about?)
<raz> anyway, on paper my new macbook should give me a 10% boost when it arrives. gonna be interesting to see if that's noticeable in practice.
<jhass> dwarf is darwin's (macos') method to store debug symbols
<raz> ahh okay.
<jhass> debug symbols are annotating what address in the binary originates from what source code and what the original name in the source code was
<FromGitter> <watzon> Doesn't DARF information get used for GDB and other debugging tools
<jhass> for example. But also printing stacktraces makes use of it
<raz> yup, i noticed my release binaries still often give me ??? instead of proper backtraces.
<jhass> in ELF (linux, bsd) this information can be embedded, that's why you don't see those files there
* raz nods
<hightower2> raz for incremental compilation etc., I found discussions about that and REPL interesting (not sure if they were on the forum or somewhere, but found them just searching on the web)
<raz> yup, i actually use the repl quite frequently (icr). it seems to be described as a naughty hack, but i find it super useful to quickly try things :D
<FromGitter> <tenebrousedge> +10000 for icr
<hightower2> See also cry, similar to icr
<FromGitter> <Blacksmoke16> `crystal playground`
<raz> ah cool, gonna check it out.
<FromGitter> <tenebrousedge> `crystal play` you mean
<FromGitter> <Blacksmoke16> oh oops
<FromGitter> <Blacksmoke16> shows how much i use it :S
<straight-shoota> or carc.in
<FromGitter> <Blacksmoke16> local playground watches for changes iirc
<FromGitter> <Blacksmoke16> essentially like icr?
<straight-shoota> yeah
<raz> oh haha, i didn't even know that's baked into crystal itself
<FromGitter> <tenebrousedge> I don't like `crystal play` it's too slow
<FromGitter> <watzon> Yeah `crystal play` is kind of a nightmare
<FromGitter> <watzon> It's handy, but man is it slow
<raz> most of the time i just try out stuff directly in the code anyway (using nodemon for auto-recompile on change)
zorp has quit [Ping timeout: 256 seconds]
<hightower2> Ah remind me pls, in macros, what constant holds the crystal version for a version check
<jhass> >> Crystal::VERSION
<DeBot> jhass: # => "0.34.0" - https://carc.in/#/r/90pw
<hightower2> ah ofc, had 'Crystal' in local module so it was hiding ::Crystal
<hightower2> thanks
postmodern has joined #crystal-lang
<FromGitter> <Afront> I should probably ask this in Slack instead of Gitter (since this is more of software recommendation), but is there a Crystal shard that allows you to create stock charts (line charts with up-down bars)? I haven't found a shard yet that (explicitly) supports this.
<FromGitter> <tenebrousedge> there isn't really a line between what's appropriate to ask here vs slack btw
<oprypin> that part about slack is really surprising, yea 😧
* FromGitter * tenebrousedge shrugs
<FromGitter> <watzon> I'd say it's more appropriate for the forum than Slack haha
<FromGitter> <watzon> But I do know there's a graph generation library, not sure if that's what you're looking for
<FromGitter> <watzon> It's a plotting library though, not charting
<FromGitter> <Afront> Oh cool, thanks! I'll check it out.
dostoyevsky has quit [Quit: leaving]
dostoyevsky has joined #crystal-lang
dostoyevsky has quit [Client Quit]
dostoyevsky has joined #crystal-lang
_ht has quit [Quit: _ht]
hightower2 has quit [Ping timeout: 246 seconds]
<repo> 43
<raz> wrong. off-by-1.
<FromGitter> <dweqv> How come crystal, unlike ruby, isn't supporting `if ... then` when there's `when ... then`?
<FromGitter> <Blacksmoke16> :shrug: its not ruby
<FromGitter> <Blacksmoke16> plus is `if expression then code` better than `code if expression`?
<FromGitter> <dweqv> Nicer than ternary or `if ...; ... else ... end` expressions, imo.
<FromGitter> <Blacksmoke16> if its not simple enough for ternary, then just use a standard multi line if/else
<FromGitter> <Blacksmoke16> prob is an issue about it somewhere
<FromGitter> <dweqv> Somewhat hard to search for, unfortunately.
<FromGitter> <watzon> > if its not simple enough for ternary, then just use a standard multi line if/else ⏎ ⏎ This
<FromGitter> <watzon> I've never been a fan of the `if ... then ... else`
<FromGitter> <watzon> Too verbose
<FromGitter> <Blacksmoke16> https://github.com/crystal-lang/crystal/issues/4117 found it
<FromGitter> <dweqv> Ah, a shame. But thank you for that link, @Blacksmoke16!
<FromGitter> <Blacksmoke16> np
<straight-shoota> @dweqv What do you mean with hard to search for?
<FromGitter> <Blacksmoke16> was kinda a pain searching for `if then` :S
<FromGitter> <dweqv> The issue itself.
<FromGitter> <dweqv> Yeah.
<FromGitter> <Blacksmoke16> turns out it was on first page of google lol
<FromGitter> <dweqv> Sweet. Had no luck with site:github.com and such.
<FromGitter> <3n-k1> does anyone know how crystalshards gets a list of crystal repos? i'd rather not dig through the code to find out if i don't have to
<FromGitter> <Blacksmoke16> scraping github/gitlab afaik
<straight-shoota> ah
<straight-shoota> yes, crystalshards.org simply queries the GitHub API
<straight-shoota> Don't think it supports Gitlab atm
<FromGitter> <3n-k1> wasn't sure if they did something special or not. thanks :)
<straight-shoota> https://shardbox.org/ uses a maintained catalog to discover shards (https://github.com/shardbox/catalog)
<FromGitter> <3n-k1> looks like i can just search for shard.yml as a filename
<FromGitter> <3n-k1> ~~i have too many projects lol~~