<FromGitter>
<drosehn> https://vimeo.com/190927958 <- There's this one that Ary did in November or December of last year, about 36 minutes.
<FromGitter>
<bew> niiice, will look this, thanks!!!!
bjz has joined #crystal-lang
elia has joined #crystal-lang
<FromGitter>
<fridgerator> Yep that's what I was looking for
<FromGitter>
<bew> The 5 points-before-going-to macro-land from the video are very interesting
bew78 has quit [Quit: WeeChat 1.7]
zipR4ND has quit [Ping timeout: 268 seconds]
elia has quit [Quit: Computer has gone to sleep.]
<FromGitter>
<bew> How can I get the compiler docs ? running `cr docs -D i_know_what_im_doing src/compiler/crystal.cr` juste tells me that file `-D` does not exists
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter>
<bew> found it! setting the `CRYSTAL_HAS_WRAPPER` env variable did the trick
txdv has quit [Ping timeout: 260 seconds]
VectorGraphics has joined #crystal-lang
VectorGraphics has quit [Ping timeout: 246 seconds]
txdv has joined #crystal-lang
bjz has joined #crystal-lang
VectorGraphics has joined #crystal-lang
<FromGitter>
<fridgerator> running into an error running `crystal docs`
<FromGitter>
<fridgerator> `Unhandled type in `name`: Crecto::Model+:Class`
<FromGitter>
<fridgerator> has anyone else seen this?
<FromGitter>
<elorest> I need to include multiple c files from libbluetooth-dev for bluez in my crystal app. In C I would include them like ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Would it be best to just include these in a c file which I then compile to an object file to bind into crystal or is there a better way to just include all of these into crystal? [https://gitter.im/crystal-lang/crystal?at=58c61346872fc8ce62f4d589]
<FromGitter>
<bew> why not directly using the libbluetooth, by creating a lib binding for crystal ?
<FromGitter>
<elorest> @bew Yes. That's what I'm doing. But I need to include all of these files in order to bind to their functions. Yesterday I figured out how to link it to a single file but how would I include multiple files. I suggested above that I could create a single c file with all of the includes with I could compile to a .o file and link to my crystal library. Is there a better way.
<FromGitter>
<elorest> @drosehn useful video. Thanks for sharing.
<FromGitter>
<bew> @elorest I don't understand why you need to include C header files
<FromGitter>
<bew> You need to create a "crystal header file" for the functions (and structures) you want to use in the library
<FromGitter>
<elorest> @bew Maybe I'm the one who doesn't understand here. To me it seems like I need to include these header files from c so I can bind their functions in crystal. Unless I want to rewrite the million lines of code that they contain in crystal...
<FromGitter>
<bew> not exactly: the C header files (all .h files) are just here to describe the functions of the libblutooth, there is no real code in thoses header files, the "real code" of the functions is in the library, and you don't need to know how it works exactly, you only need to know how to call the functions. This is all the header file is about! As the C header files are the description on how to call the real function from C
<FromGitter>
... kind of Crystal header file, to explain to crystal how to call the real function from Crystal. (tell me if it's not clear enough @elorest )
<FromGitter>
<bew> the C header files describe aaaaalll the available functions in the library, and I don't think you'll use all of them, so the crystal-header can only contains the function description you'll need (so you don't have to rewrite aall thoses headers)
<FromGitter>
<elorest> @bew Thanks for being patient. I was under the understanding that including these h files also compiled in the implementation files. In c I don't need to include the implementation files to actually get reference their functions. I assumed this would be the same with crystal. I guess I'd need to include <bluetooth/bluetooth.c> or something instead?
<FromGitter>
<elorest> All I want to do is get access to (most) of the functions contained within the c implementation files that those 7 headers are for.
<FromGitter>
<drosehn> You need to know the C declarations for the functions that you're interested in, and write matching definitions in crystal. But your project would not directly include any `*.c` or `*.h` files.
<FromGitter>
<elorest> @drosehn @pew Thanks. So how would I link them to my crystal project? Something like `[Link()]`? I understand how to bind to the functions once I have them (included? linked?) as the documentation covers that well. What I'm confused about is how I include them in the first place. This is what I'm trying to bind too: http://packages.ubuntu.com/precise/amd64/libbluetooth-dev/filelist
<FromGitter>
<bew> it means that this attribute in not included in the official compiler, you need a custom compiler (so no, compiler from master won't compile it)
unshadow has joined #crystal-lang
<FromGitter>
<bararchy> Oh.... I see
<FromGitter>
<bararchy> @bew Thanks :)
unshadow has quit [Client Quit]
<FromGitter>
<bararchy> So if I use hes custom compiler I could use that right ?
<FromGitter>
<bararchy> @bew TBH this feature\ability sounds like a great thing no ? why isn't it merged into Master ? would it cause issues for programs not using it (does it have global effect?)
<FromGitter>
<bew> I don't know, maybe it is experimental, and not currently discussed with the crystal core devs
<FromGitter>
<neovintage> @fridgerator do you run tests against mysql for crecto? I just tried doing it for the adapter tests and I'm getting a couple of errors
<FromGitter>
<neovintage> I can fix them as part of the adapter stuff but I want to make sure I'm not doing something I shouldn't be
<FromGitter>
<fridgerator> I do, but I usually change things to run them, then change them back, lol
<FromGitter>
<neovintage> @fridgerator ok. I'm going to separate out the testing in the travis.yml file, so that we could do both as part of the build.
<FromGitter>
<fridgerator> awesome!, If you need I can send you the things that I change when I run mysql tests
<FromGitter>
<neovintage> is it anything beyond changing the env var ?
<FromGitter>
<fridgerator> yeah
<FromGitter>
<fridgerator> let me make a list
<FromGitter>
<neovintage> @fridgerator thanks
<FromGitter>
<fridgerator> I posted them in the crecto channel
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 240 seconds]
gk-- has joined #crystal-lang
<FromGitter>
<bew> What is this syntax `Set{1, 2, 3}` ? can I use this in my own classes ? how
gk-- has quit [K-Lined]
<BlaXpirit>
bew, yes, your class needs to support initialize without arguments and << with one argument
<Yxhvd>
oh, nice
<BlaXpirit>
can;t find it in docs for the life of me
<FromGitter>
<bew> nice, thanks BlaXpirit!
<BlaXpirit>
and well it calls s=Set.new; s<<1;s<<2;s<<3 but u probably guessed
<FromGitter>
<bew> yes, thanks!
<crystal-gh>
crystal/master f1a1adb Brandon McGinty-Carroll: allow setting and deleting of attributes on supported XML::Node types (#3902)...
<crystal-gh>
[crystal] bcardiff pushed 1 new commit to master: https://git.io/vyiPt
<BlaXpirit>
actually it's not that simple, now that I remember. it calls Set(typeof(1, 2, 3)).new
<BlaXpirit>
so the class probably needs to be a generic with a matching type
<FromGitter>
<bew> hmm so my class needs to be generic?
<FromGitter>
<bew> I see
<FromGitter>
<bew> It works like you said so yes, must be generic
akwiatkowski has joined #crystal-lang
<FromGitter>
<zatherz> are there any plans to add a generic reinterpret cast method?
<FromGitter>
<zatherz> something like `15.reinterpret(String) #=> "15"`
<FromGitter>
<bew> `15.to_s` ?
Ven has joined #crystal-lang
<FromGitter>
<zatherz> I mean, a general method to do things like that. `"15".reinterpret(Int32) #=> 15_i32`
<FromGitter>
<zatherz> one area where it'd be useful
<FromGitter>
<zatherz> is in JSON mappings
<FromGitter>
<zatherz> since it'd allow for non-string-key hashes
<FromGitter>
<zatherz> basically, a method to call on the object with the target *type*, notmultiple methods with a potentially inconsistent and limited scheme
<FromGitter>
<bew> you want to make converters, but it's always the same problem: you'll still have inconsistencies and limited scheme I think..
<BlaXpirit>
zatherz, it's too magical. no such plans
<FromGitter>
<zatherz> but if I wanted to have an object that takes a string in its initializer, but also make it possible to reinterpret-cast a string into it
<FromGitter>
<zatherz> I'd be forced to implement a separate method for that
<BlaXpirit>
and that's certainly not what reinterpret cast means
<FromGitter>
<zatherz> yeah, sorry, `.as` is already kind of a reinterpret cast
<FromGitter>
<zatherz> you know what I mean though
<BlaXpirit>
no, that's static cast
<Yxhvd>
what problem are you solving?
<BlaXpirit>
something with json was mentioned above
<FromGitter>
<zatherz> BlaXpirit am I not understanding this correctly? "Unlike static_cast, but like const_cast, the reinterpret_cast expression does not compile to any CPU instructions. *It is purely a compiler directive* which instructs the compiler to treat the sequence of bits (object representation) of expression as if it had the type new_type.", static cast - " If there is an implicit conversion sequence from expression to new_typ
<FromGitter>
... overload resolution for a direct initialization of an object or reference of type new_type from expression would find at least one viable function, then static_cast<new_type>(expression) returns the imaginary variable Temp initialized as if by new_type Temp(expression);, *which may involve implicit conversions ... [https://gitter.im/crystal-lang/crystal?at=58c6e33909e7ba8510bdff80]
<Yxhvd>
that could be solved better. I wouldn't mind the json builder automatically calling .to_s. Convention > magic
<FromGitter>
<zatherz> isn't that kind of magic though
<FromGitter>
<zatherz> also the convention isn't too clear
<BlaXpirit>
why not
<BlaXpirit>
.to_s applies to everything
<FromGitter>
<zatherz> if I have an object SomeSortOfObject, what do I use? `to_s` is taken
<BlaXpirit>
umm use to_s
<FromGitter>
<zatherz> for conveting *into* SomeSortOfObject
<BlaXpirit>
ah ok. no, there is no such convention
<FromGitter>
<zatherz> exactly
<Yxhvd>
I'd suggest you use something else then, as to_s is used all over the place for converting to string.
<BlaXpirit>
even in c++, where this is possible, it's considered a bad practice
<BlaXpirit>
you can use SomeSortOfObject.new(from_value)
<FromGitter>
<zatherz> Yxhvd it's just a hypothetical situation supposed to demonstrate that there is no convention apart from the builtin objects
<Yxhvd>
eh, what is a convention except common practice?
<Yxhvd>
the former is convention. The latter would confuse people as they expect it to be a string.
<FromGitter>
<zatherz> I'm not sure if you're doing this intentionally
<FromGitter>
<zatherz> the point is that there is no way to just express "convert this into type X", which means that for example in the case of JSON mappings
<FromGitter>
<zatherz> you can not have a hash with a key type other than String
<FromGitter>
<zatherz> sure, you could `to_s` when serializing
<FromGitter>
<zatherz> but what do you use when deserializing?
<FromGitter>
<bew> `from_s` ?
<BlaXpirit>
implicit conversions are not a solution anyway
<FromGitter>
<bew> true
<FromGitter>
<zatherz> I guess you could use a converter
<FromGitter>
<zatherz> actually, I don't know why I didn't think of that
<FromGitter>
<zatherz> by the way, is there some sort of built in solution for "hooks"? like, if I wanted to expose the ability to add procs that are called right before a method
<FromGitter>
<zatherz> with stuff like op overloads
Ven has quit [Ping timeout: 260 seconds]
<FromGitter>
<zatherz> just want to know so that I don't reinvent the wheel
<FromGitter>
<bew> op overload yes
<FromGitter>
<bew> do you have an example for hooks ?
Ven has joined #crystal-lang
<FromGitter>
<dreyks> you mean something like callbacks and aspect-oriented programming?
<FromGitter>
<zatherz> is there any way to expand generic type arguments like that?
<Papierkorb>
It's not about hooks though, it's more about decoupling update/reaction paths in your application
<FromGitter>
<zatherz> `Proc(*T, Nil)` was obviously the first thing I tried, but it doesn't do what I expect
sija has quit [Quit: Connection closed for inactivity]
Ven has quit [Ping timeout: 260 seconds]
<FromGitter>
<bew> cute is a nice lib Papierkorb!
<FromGitter>
<dreyks> @Papierkorb yes, hooks are ways to achieve decoupling here
<Papierkorb>
dreyks, if you don't need a response from it, you can use that shard. I didn't need that feature back when I wrote it, though with a sane and nice API, I'd have no issues adding that feature
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<txdv>
i think this is what i need
<txdv>
too bad slice doesnt include iterator
<BlaXpirit>
txdv, yeah probably, as long as you remember not to use yield because it has a different meaning
<BlaXpirit>
txdv, uhm actually things just work differently
<BlaXpirit>
txdv, Iterator is a mutable view over a sequence of elements. Iterable or Enumerable is what you include to say that this class has a sequence of elements
<BlaXpirit>
the discouraging things i was saying above just meant that it's nontrivial to create an implementation of Iterator. you use clases and manual state tracking instead of just yield like in C#
<Yxhvd>
BlaXpirit: Ruby has call/cc for the pause and continue at will use case, but it is more than a bit inefficient.
<pnshrmp>
what am I doing wrong?
<BlaXpirit>
pnshrmp, you're using yield inside a proc literal
<BlaXpirit>
what are you trying to do?
<Yxhvd>
he is basically doing spawn { yieild(x) }
<Yxhvd>
modulo spelling
<Yxhvd>
I suppose spawn converts the block to a proc?
<pnshrmp>
a method that accepts a block in similar fashion to Int32.times but spawns a new fiber for each 'iteration' and cap concurrency with a channel
<pnshrmp>
yeah looks like that is the problem, how do I solve it ?
<pnshrmp>
(I'm a total beggines with crystal or even ruby)
<pnshrmp>
I red the linked documentatino page and tried passing a block parameter instead. Bit the code inside spawn{} wouldn't execute anyway
<BlaXpirit>
i don't know where to start fixing this :/
<BlaXpirit>
first of all, sending and receiving to the channel must happen at the same time
<BlaXpirit>
channel.send(0) just blocks forever here
<BlaXpirit>
basically you need to spawn fibers which do channel.send
<BlaXpirit>
and the main one would yield channel.receive
<BlaXpirit>
or something
<pnshrmp>
mmm... I don't intend to opose, but psasing a block that is not an issues, it doesn't block on send
<BlaXpirit>
it's hard to say anything because how are you supposed to get concurrency without any actual computations
<pnshrmp>
notice the channel constructor with a capacity that can be larger than zero
<pnshrmp>
*constructor call
<BlaXpirit>
pnshrmp, you are right. sorry.
<pnshrmp>
BlaXpirit, not sure the code is very clear. What I want to do is spawn as many times as the channel allow... basically just use the channel as aquire() and release()
<pnshrmp>
I want to pass a block with the actual code to execute inside fibers
<pnshrmp>
the goal is to cap the amount of simultaneous fibers
<pnshrmp>
I think I am rather close, except I can't put yield inside spawn apparently
<pnshrmp>
is it possible to convert a yielded block to a proc? how? I could convert it right before spawn
<pnshrmp>
wait wait... that looks like my last attempt
<pnshrmp>
where is the difference?
<pnshrmp>
looks the same...
<pnshrmp>
there must be a difference
<RX14>
channel.recieve is in the spawn
<RX14>
also
<RX14>
there's a sleep
<RX14>
which means your fiber gets rescheduled
<BlaXpirit>
well the crystagiri would take some time to download the doc u know, that would've worked, i just wanted to replace it so it can run on carcin
<pnshrmp>
BlaXpirit, aaaaaaaaaahhhh!!!!! that detail
<pnshrmp>
of course
<BlaXpirit>
now the problem is synchronization, counter gets a race condition
<pnshrmp>
does it really?
<pnshrmp>
looks like it worked in your example...?
<BlaXpirit>
see 2 2 2 at the start
<BlaXpirit>
instead of 0 1 2
<BlaXpirit>
pnshrmp,
<pnshrmp>
yeah I see
<pnshrmp>
and it throws me some cryptic errors in the first http requests too :/
<pnshrmp>
but I don't understand the problem
<BlaXpirit>
errors shouldn't happen
<BlaXpirit>
I'm gonna work
<pnshrmp>
thanks for the help
<pnshrmp>
oh well i'm also going to sleep... will come back anoter day
<pnshrmp>
ty everyone
pnshrmp has left #crystal-lang ["Leaving"]
<Papierkorb>
dreyks, if you haven't already, please have another look at the cute shard. I added middleware support to it