ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.23.1 | 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
<FromGitter> <faustinoaq> Hi crystal comminity!, I just got an idea, Would be posible an implementation of ruby using crystal?
<FromGitter> <faustinoaq> very interesting: first ruby to compile crystal, then crystal to compile crystal, and finally crystal to compile ruby 😅
<FromGitter> <faustinoaq> https://github.com/asterite/crystal
<FromGitter> <andrewhamon> When integrating with a C lib, does anyone know how the garbage collector will behave if it encounters a reference to memory not allocated by crystal?
<FromGitter> <andrewhamon> I'm somewhat interested in wrapping the secure memory helpers from libsodium
<FromGitter> <andrewhamon> So i was thinking I might make a wrapper that extends `Slice` but allocates memory using the sodium and deallocates using the `finalize` hook
<FromGitter> <johnjansen> anyone got a sample Makefile for a crystal project, for reference?
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
onionhammer1 has joined #crystal-lang
onionhammer has quit [Ping timeout: 248 seconds]
onionhammer1 has quit [Ping timeout: 260 seconds]
onionhammer1 has joined #crystal-lang
Disrecollection has quit [Ping timeout: 276 seconds]
snsei has joined #crystal-lang
pwned has joined #crystal-lang
Disrecollection has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
hightower has joined #crystal-lang
<FromGitter> <drosehn> I have never tried it, but I think you use `crystal init` to create a project, and then when you're in that project you'd use `shards build` to build it. So I *think* you care about `shard.yml` instead of a Makefile. However, I haven't read the documentation for any of that. 😄
<FromGitter> <johnjansen> yeah, its more about the build then install process on another machine … ideally from `.o` files i think? but i havent tried before either … i want to get to the point where i can `make && make install` on another machine … so much to learn ;-)
<FromGitter> <johnjansen> the Makefile in crystal is interesting to say the least https://github.com/crystal-lang/crystal/blob/master/Makefile
<FromGitter> <johnjansen> i think i might have the wrong end of the stick so to speak … but anyhoo … learning about this kind of release process is a new experience for me
<FromGitter> <drosehn> All of my crystal projects are pretty simple, and most of them are probably a single source file. So while I do use makefiles (instead of shards), they're pretty simple-minded makefiles. Nothing like the one for crystal!
<FromGitter> <johnjansen> got an example of one of yours that i could look at
<FromGitter> <johnjansen> i have one, but id be interested in wether i have to approach right
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<FromGitter> <drosehn> Mostly variations of:
<FromGitter> <drosehn> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=597034f71c8697534a405cbb]
<FromGitter> <johnjansen> thanks Garance
<FromGitter> <drosehn> that's pretty simple-minded. and I'm not compiling anything to `*.o` files. If a project has multiple source files, I'm just building one `*.cr` file and then that source file `require`s the other ones.
<FromGitter> <johnjansen> mine was dead simple … although more than one file per project, but … ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5970366d0de4d2545e4591af]
<FromGitter> <johnjansen> worked though :-)
hightower has quit [Ping timeout: 248 seconds]
<FromGitter> <andrewhamon> @johnjansen you can specify build targets in shards.yml
<FromGitter> <andrewhamon> ```targets: ⏎ foo: ⏎ main: src/foo.cr ⏎ bar: ⏎ main: src/bar.cr``` [https://gitter.im/crystal-lang/crystal?at=59703b38bc4647297408ed52]
<FromGitter> <andrewhamon> and then build with `shards build`
<FromGitter> <andrewhamon> Or in your case, `shards build --release --no-debug`
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter> <andrewhamon> Which may not be flexible enough for you, but possibly worth noting :)
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<oprypin> andrewhamon, only GC.malloc allocations are tracked
hightower2 has joined #crystal-lang
Disrecollection has quit [Ping timeout: 258 seconds]
hightower3 has joined #crystal-lang
hightower4 has quit [Ping timeout: 248 seconds]
hightower4 has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
olbat has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
mark_66 has joined #crystal-lang
Disrecollection has joined #crystal-lang
Groogy has quit [Ping timeout: 248 seconds]
Yxhuvud has quit [Ping timeout: 248 seconds]
Yxhuvud has joined #crystal-lang
Groogy has joined #crystal-lang
Disrecollection has quit [Ping timeout: 248 seconds]
<Groogy> Morning!
Disrecollection has joined #crystal-lang
<FromGitter> <bew> Morning Groogy ;)
<FromGitter> <ezrast> Can someone explain what all the `typeof` statements do in, e.g., https://github.com/crystal-lang/crystal/blob/master/spec/std/http/client/client_spec.cr ?
Disrecollection has quit [Ping timeout: 240 seconds]
Disrecollection has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<FromGitter> <bew> Didn't know that trick until now, I think it's to make fake usage of functions, to ensure that a given function can be compiled with this or that argument, without having to make complete specs for them.
<FromGitter> <sdogruyol> Morning everyone
<FromGitter> <sdogruyol> @groogy
<FromGitter> <bew> doing `typeof(some_method "arg1", :arg2)` forces the cmopiler to try to instanciate the method with the given arguments, to get the result type. If something is wrong in the method (a bad call, an unknown variable, or another semantic error), the compiler will give you an error for that method.
<FromGitter> <bew> Hi!
<Groogy> That is a nice tool to have
crack08 has joined #crystal-lang
hightower2 has quit [Ping timeout: 240 seconds]
hightower4 has quit [Ping timeout: 268 seconds]
Disrecollection has quit [Ping timeout: 246 seconds]
<Yxhuvud> It is, though if I just want to have the compiler look at it my first goto solution is to write a test :)
<FromGitter> <romain1189> Hello everyone
<FromGitter> <romain1189> Is there a way to pass link flags to `crystal spec` ?
<Yxhuvud> crystal spec answers to --release flags, so I'd assume the same is true for link flags
<FromGitter> <straight-shoota> I don't think this is possible, at least not directly with `crystal spec`. you might be able to set some environment variables that are used by the linker.
<FromGitter> <straight-shoota> setting `LD_LIBRARY_PATH` and `LIBRARY_PATH` works, but I don't know about flags.
<FromGitter> <bew> what kind of link flags do you need? are you writing a binding?
<FromGitter> <straight-shoota> @oprypin is the man to got to
<FromGitter> <romain1189> @bew I'm writing bindings for MPI (https://github.com/romain1189/mpi.cr). I'm fighting to setup travis.
<FromGitter> <romain1189> `LD_LIBRARY_PATH`is set but I'm getting `/usr/bin/ld: cannot find -lmpi` anyway. Specifying the path through link flags using -L works to build examples. I was hoping I could do the same thing with `crystal spec`
<FromGitter> <bew> you can add `-L/path/to/lib` in your code as `@[Link("mpi", ldflags: "-L/path/to/lib)]` to make it work for all compilation that needs the lib I think
<FromGitter> <romain1189> I thought about it but this would mean the library needs to be built overytime, not just for CI
<FromGitter> <romain1189> I'll just use apt packages from travis, the linker should find them
<FromGitter> <bew> if you can install the lib via a package, it's the easiest way (until you need a specific version of the lib maybe..)
<FromGitter> <bararchy> LOL @codenoid --> https://github.com/codenoid/chuck-norris-holy-quotes.git
hightower4 has joined #crystal-lang
hightower2 has joined #crystal-lang
<FromGitter> <muhajirframe> Hi guys, a little bit problem as I am getting started with crystal. So I read basic HTTP Server with Crystal. ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ And I have question, ( I have no ruby experince before, just Javascript): ... [https://gitter.im/crystal-lang/crystal?at=59708853329651f46ea65603]
<Yxhuvud> muhajirframe: require "http/server" simply loads the server.cr file in the http directory. What symbols that get defined is totall up to the file.
<FromGitter> <muhajirframe> Hmm, is it possible to define it like , require http/server as something ?
<Papierkorb> no
<Yxhuvud> that question makes no sense.
<FromGitter> <straight-shoota> In Crystal all symbols (like class or module) live in the same global scope. Once a file is required, all it's contents are visible everyehere.
<FromGitter> <straight-shoota> *everywhere
<FromGitter> <straight-shoota> So namespacing happens when they are defined. In your example, the class `Server` is defined inside the `HTTP` namespace. And it is accessible as `HTTP::Server` from any location in the program.
<FromGitter> <straight-shoota> Yxhuvud, the question itself makes perfect sense. It refers to the concept of namespaced local imports, which is widely used in JavaScript among others. This has also been proposed for Crystal in #4439 though it's not going to happen (for now).
<FromGitter> <muhajirframe> Is there any plan to make the definition more scoped? For example in node js we `var something = require('http')` , in python `import package as something`. In my opinion it is easier to understand as we know where does it comes from.
<RX14> no, we plan to stick to how ruby (pretty sucesfully) does it
<Papierkorb> I too enjoy not having `require`/`import` spam in each file
<FromGitter> <muhajirframe> Okay, I'll take a look how to write code in ruby way.
<FromGitter> <muhajirframe> What's the meaning of `spam` here
<FromGitter> <muhajirframe> ?
<FromGitter> <straight-shoota> having lots of identical lines with imports at the beginning of every file
<RX14> it's faily easy to keep a mental model of what library owns each namespace then look up the docs for that library
<FromGitter> <straight-shoota> that makes no sense when the files are not individually used but all are combined together in one program
<FromGitter> <muhajirframe> Ah, I get what you mean.
<FromGitter> <muhajirframe> What if there's two mod
<Yxhuvud> If two required libraries define entities with the same name, then there would probably be a problem. But I've never had that happen neither in ruby nor in crystal. The closest is when two requires define or redefine methods in namespaces they don't own, I've had that happen once or twice during the years.
<FromGitter> <rishavs> Hi guys. I am trying out multi_auth library. when i authenticate via oauth and then redirect back to my webapp, i get this error.
<FromGitter> <rishavs> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5970a4fabf7e6af22cf8b41e]
<FromGitter> <straight-shoota> So, you're missing a hash key.
Philpax has joined #crystal-lang
Philpax_ has joined #crystal-lang
greengriminal has joined #crystal-lang
Philpax has quit [Ping timeout: 240 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter> <rishavs> does it have something to do with https?
greengriminal has joined #crystal-lang
<FromGitter> <straight-shoota> No. You are trying to read a value from a hash with a key that does not exist
<FromGitter> <straight-shoota> you're probably need setup for the provider
<FromGitter> <rishavs> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5970b312c101bc4e3aa3a919]
<FromGitter> <rishavs> thats pretty much my code
hightower2 has quit [Ping timeout: 246 seconds]
hightower4 has quit [Ping timeout: 240 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter> <straight-shoota> I don't know what multi_auth is doing, but you should take a look at method primary? in /home/rick/DevSpace/Crystal/Kamel/lib/multi_auth/src/multi_auth/providers/google.cr 68:5
greengriminal has joined #crystal-lang
<FromGitter> <rishavs> thanks
Philpax_ has quit [Ping timeout: 260 seconds]
<FromGitter> <watzon> In a macro definition how would you add commas to things in a for loop? For instance: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5970c69d4bcd78af56cc16d5]
<FromGitter> <bew> you can add a comma, trailing comma are not an issue
<FromGitter> <bew> `def func(a, b, c, ); puts a, b, c; end` works
<FromGitter> <watzon> No? Then my error must be for another reason
<Papierkorb> watzon, also, don't use leading underscore variable names. These variable names are, by convention, reserved for unused-but-named arguments.
<FromGitter> <watzon> Gotcha. Thanks
<Papierkorb> watzon, e.g., when you have a block which takes arguments, but you don't care about specific ones. Superficial example: `some_hash.each{|_key, value| ...}` - Here you tell the reader of your code that you know about the first argument, but you really don't care about it
<FromGitter> <watzon> I forgot the `super` 👏
<FromGitter> <watzon> Is there an easy way to inspect the code that a macro will generate?
<Papierkorb> watzon, yes: `{{ debug() }}` put that somewhere in the macro
<Papierkorb> That'll then dump the generated macro code onto stdout when compiling
<FromGitter> <watzon> Awesome! Thanks
mark_66 has quit [Remote host closed the connection]
<Yxhuvud> there is also a command line switch to crystal where you give it a region and tell it to macroexpand it
<Yxhuvud> crystal tool something
<FromGitter> <bew> `crystal tool expand` ?
<Yxhuvud> yeah.
* Yxhuvud have tought his editor how to do it. The syntax of the arguments is a bit nonintuitive.
Renich has joined #crystal-lang
<FromGitter> <watzon> How do you use the `@type` helper? I'm trying to get the type of a NamedTuple that's passed into my macro
<FromGitter> <watzon> Never mind, I figured it out
hightower3 has quit [Remote host closed the connection]
<FromGitter> <watzon> ```code paste, see link``` ⏎ ⏎ Any idea why this wouldn't be picking up `Node`'s instance variables? I just get an empty array [https://gitter.im/crystal-lang/crystal?at=5970d8bdc101bc4e3aa46739]
<FromGitter> <bew> It's because the instances variables may be not all known at the time this macro runs
Groogy2 has joined #crystal-lang
Groogy has quit [Disconnected by services]
Groogy2 is now known as Groogy
Groogy_ has joined #crystal-lang
<FromGitter> <bew> I'm not sure how to explain *clearly* whats going on, even if I know it.. If someone knows how to clearly explain that, please go ahead
<FromGitter> <watzon> Is there a way to make sure a macro runs after a class has been defined?
<FromGitter> <bew> iirc, thoses are called `macro def`, but I never really used them
<FromGitter> <bew> what are you trying to do?
<FromGitter> <johnjansen> i dont know, but id try declaring them in the class explicitly and see how that goes … ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5970db43c101bc4e3aa47345]
<FromGitter> <watzon> Have any idea where I could find documentation on macro def? I'm making a macro that makes it easy to extend a class with a boilerplate. I want to make sure that the parent's methods get extended though
<FromGitter> <watzon> @johnjansen just tried it, doesn't work unfortunately
<FromGitter> <johnjansen> oh well :-/ …
tzekid has joined #crystal-lang
tzekid has quit [Remote host closed the connection]
<FromGitter> <drosehn> https://crystal-lang.org/docs/syntax_and_semantics/macros.html -- might give you some of the info you want.
<FromGitter> <drosehn> https://crystal-lang.org/api/Crystal/Macros.html -- this might give you some more.
<Papierkorb> watzon, sounds like you're looking for the inherited hook
<FromGitter> <watzon> Papierkorb: I was just looking at that, but I can't figure out how to make it work with my code
<Papierkorb> watzon, what is your exact use case?
<Papierkorb> What functionality are you trying to implement?
<FromGitter> <watzon> The macro that I made generates classes that are children of another class
<Papierkorb> Children? You mean, they inherit from another class?
<FromGitter> <watzon> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5970e02f614889d475d39b57]
<FromGitter> <watzon> This is it so far
<FromGitter> <watzon> Right now it's not able to get the instance variables of the parent class though
<Papierkorb> I don't see why you'd create an all new class. Rather, it looks like the `mapping` macro pattern employed by e.g. JSON and YAML
<FromGitter> <watzon> This is partially for experimentation purposes, but I do need to create several classes that are mostly dummies for holding data. I could go make them all by hand, but I figured this would be a good exercise
<Papierkorb> Have a look at the existing mapping macro's, my guess is that they do almost exactly what you're trying to do
<FromGitter> <johnjansen> i think im missing the point too …
<Papierkorb> Or maybe the `record` macro
<Groogy> Hello!
<FromGitter> <watzon> This is what I'm trying to do more or less https://github.com/straight-shoota/crinja/blob/master/src/crinja/parser/ast.cr
<FromGitter> <watzon> That file should help me
pwned has quit [Ping timeout: 255 seconds]
pwned has joined #crystal-lang
<FromGitter> <crisward> @RX14 You about?
<RX14> yes
<FromGitter> <crisward> I seem to remember you'd been messing with test coverage in crystal, do you have any example configs anywhere?
<FromGitter> <crisward> kcov?
<RX14> just use it normally
<RX14> kcov has no config
<FromGitter> <crisward> did you build from source or is there an osx binary somewhere?
<RX14> idk i've never used osx
<RX14> i just installed kcov with my package manager
<FromGitter> <crisward> Ok, thanks anyway, will have a look around. Brew, which is kind of apt on osx doesn't seem to have it. I'll follow the build instructions and see how I get on.
<FromGitter> <johnjansen> @RX14 what platform are you on and what editor do you use … ooi
<RX14> i use archlinux and emacs
<FromGitter> <johnjansen> thanks ;-)
<RX14> why? just for interest?
<FromGitter> <johnjansen> always interested in looking at other options
<RX14> I really like spacemacs because it uses vim keybinds so I didn't have to change my editing workflow coming from vim
<RX14> takes a while to learn how to get around though
<RX14> the main draw to spacemacs for me was that it seemed to support multiple screens much better than gvim
<RX14> so I could just press a keyboard combination and open the same file on my second monitor
<RX14> instead of vim where you need 2 editor processes which can conflict
<FromGitter> <johnjansen> cool … are there any good starting points for spacemacs email
<FromGitter> <johnjansen> emacs
<FromGitter> <johnjansen> not email
<RX14> then after that i discovered magit and it was like the only git gui i preferred to commandline
<RX14> @johnjansen the website is a good start
<FromGitter> <crisward> I used sublime for everything until last yr, using vscode now. Do quite a bit of typescript as well as crystal.
<FromGitter> <johnjansen> yeah thanks @RX14 im looking at the site ;-)
<RX14> getting spacemacs as you like it is probably as hard as a good vim config
<RX14> so it's not for everyone
pwned has quit [Ping timeout: 240 seconds]
<Groogy> exit
Groogy has quit [Quit: WeeChat 1.9]
<FromGitter> <crisward> @RX14 got it installed etc... running `kcov ./crystal_cov crystal spec` but getting an empty coverage report. Any idea what I'm doing wrong?
<RX14> well you have to run it on a binary
<RX14> it won't work with subprocesses
<RX14> there isn't actually a crystal spec flag which produces a binary so you'll have to create an all_spec.cr most likely
<FromGitter> <crisward> @RX14 ok, that makes sense. Should be able to just require with a glob. Will give it a go.
<FromGitter> <crisward> Compiled my tests into an exec, running kcov on it now, seems to be taking a while. 3 mins at 95% cpu...
<RX14> @crisward what os?
<FromGitter> <crisward> Mac - upto 8 mins now, I'm guessing there is something not right. No output, though it has created the test dir.
<Yxhuvud> Try it with --release also to compare. I've had tests that has been sluggish without that
<FromGitter> <crisward> The tests run very quickly, just not via kcov. It looks like it's hanging. Can't ctl+c out of it.
<RX14> well kcov worked for me no issue
<RX14> i assume you built a recent version
<FromGitter> <crisward> There seem to be a few open osx issues, I'll check through them, if all else fails I'll run them in my vm, or docker.
<FromGitter> <crisward> yes I pull from github, and built from source
A124 has quit [Quit: '']
<FromGitter> <crisward> Found this issue - https://github.com/SimonKagstrom/kcov/issues/135#issuecomment-258865626 ie it works but very slow...
A124 has joined #crystal-lang
<RX14> ah so mac sucks as usual
<FromGitter> <crisward> harsh...
<FromGitter> <johnjansen> thats what i was thinking ;-)
<FromGitter> <fridgerator> we enjoy our outdated system libraries, mmmkay?
Disrecollection has joined #crystal-lang
tzekid has joined #crystal-lang
tzekid has quit [Client Quit]
hightower has joined #crystal-lang
<FromGitter> <elorest> ilo
crack08 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
hightower has quit [Ping timeout: 248 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
Disrecollection has quit [Quit: Leaving.]
greengriminal has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
Renich has quit [Quit: Renich]
greengriminal has quit [Quit: This computer has gone to sleep]
Disrecollection has joined #crystal-lang