asterite changed the topic of #crystal-lang to: #crystal-lang The Crystal programming language | http://crystal-lang.org | Crystal 0.6.1 | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/manastech/crystal - Docs: http://crystal-lang.org/docs/ - API: http://crystal-lang.org/api/ - Logs: http://irclog.whitequark.org/crystal-lang
waterlink has quit [Ping timeout: 246 seconds]
DerisiveLogic has joined #crystal-lang
DerisiveLogic has quit [Remote host closed the connection]
DerisiveLogic has joined #crystal-lang
<vikaton> Question
<vikaton> do the files that have ecr have to end with file.ecr ?
sfcgeorge has quit [Quit: Textual IRC Client: www.textualapp.com]
asterite has joined #crystal-lang
<asterite> To those wondering, the change to single letters has nothing to do with performance
<asterite> Single uppercase letter is used for free vars
<asterite> >> def foo(x : T); T; end; foo 1
<DeBot> asterite: Sorry, that took too long.
<asterite> Well, that should print Int32
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
<asterite> but in generic types, like Array(T), you can use T as a free var, or to match something
<asterite> (match something once the array is instantiated, free var if it's not instantiated)
<asterite> and since free vars are single-letter, type vars must also be single-letters
asterite has quit [Client Quit]
ismaelga has quit [Remote host closed the connection]
asterite has joined #crystal-lang
<asterite> another option could have been using new syntax for free vars, like def foo(x : T') or something, but that adds more noise and syntax. We think the single letter rule is a simple rule and a good compromise
asterite has quit [Client Quit]
Cidan is now known as zz_Cidan
<vikaton> wait w0t
<vikaton> im confused
asterite has joined #crystal-lang
<asterite> >> Int32
<DeBot> asterite: Int32
<asterite> >> def foo(x : T); T; end; foo 1
<DeBot> asterite: Int32
<asterite> >> Array.new(10, 0)
<DeBot> asterite: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
<asterite> >> Array(Char).new(10, 0)
<DeBot> asterite: Error in line 3: no overload matches 'Array(Char)#initialize' with types Int32, Int32
<asterite> See? That method, `new`, has a type restriction T. If you don't specify the generic type of the array, it is used as a free var to deduce the type
<asterite> However, when you specify it, it becomes a restriction against the specific type (in this case Char)
<asterite> So the T in the constructor is acting both as a free var and as a type restriction, depending on the use case
<asterite> Previous to that commit, anything that was not found (say, x : Something) was considered a free var, but that's bugprone. So we changed the rule to: free vars are single uppercase letters. With that rule, we must force generic type vars to be single uppercase letters.
<asterite> It's kind of hard, but that's the reason :)
<asterite> >> def foo(x : Integer); "hello"; end; foo 1.5
<DeBot> asterite: "hello"
<asterite> That's the bug-prone thing, in the next release that will be an error
<vikaton> nice
ismaelga has joined #crystal-lang
asterite has quit [Client Quit]
havenwood has quit [Remote host closed the connection]
ismael has joined #crystal-lang
ismael is now known as Guest91219
ismaelga has quit [Ping timeout: 240 seconds]
willlll has quit [Quit: willlll]
havenwood has joined #crystal-lang
<vikaton> >> 5.hours
<DeBot> vikaton: Sorry, that took too long.
<vikaton> >> 5.seconds
<DeBot> vikaton: Sorry, that took too long.
<vikaton> >> "ji"
<DeBot> vikaton: "ji"
<vikaton> >> 5.seconds
<DeBot> vikaton: 00:00:05
<fowl> O.o
<vikaton> yeahh
<vikaton> p cool
<vikaton> >> 1.minutes + 5.seconds
<DeBot> vikaton: 00:01:05
<fowl> Why does it sometimes take too long
<vikaton> im not sure
havenwood has quit []
willlll has joined #crystal-lang
shama has joined #crystal-lang
Guest91219 has quit [Remote host closed the connection]
zz_Cidan has quit [Ping timeout: 240 seconds]
Cidan has joined #crystal-lang
shama has quit [Remote host closed the connection]
shama has joined #crystal-lang
shama has quit [Ping timeout: 272 seconds]
shama has joined #crystal-lang
kulelu88 has left #crystal-lang ["Leaving"]
kulelu88 has joined #crystal-lang
kulelu88 has left #crystal-lang ["Leaving"]
willlll has quit [Quit: willlll]
willlll has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
willlll has quit [Quit: willlll]
willlll has joined #crystal-lang
shama has quit [Remote host closed the connection]
willlll has quit [Quit: willlll]
vegai has joined #crystal-lang
ponga has joined #crystal-lang
<vegai> hello, everybody
shama has joined #crystal-lang
<vegai> anyone thought about package/dependency management yet?
HakanD_ has joined #crystal-lang
<vegai> oh, I see there's already something in the crystal tool, nice.
shama has quit [Ping timeout: 244 seconds]
<fowl> there is?
<vegai> deps install project dependencies
<vegai> dunno exactly what it does, though :)
<vegai> reads the Projectfile and something
<fowl> Crystal needs an angel who loves to write documentation
<vegai> yes, seems a bit thin at the moment
<vegai> http://crystal-lang.org/docs/ seems good for the parts that are written, though
Ven_ has joined #crystal-lang
HakanD_ has quit [Quit: Be back later ...]
Ven_ has quit [Read error: No route to host]
DerisiveLogic has quit [Ping timeout: 276 seconds]
HakanD_ has joined #crystal-lang
waterlink has joined #crystal-lang
BlaXpirit has joined #crystal-lang
shama has joined #crystal-lang
shama has quit [Ping timeout: 265 seconds]
Ven_ has joined #crystal-lang
HakanD_ has quit [Quit: Be back later ...]
leafybasil has quit [Remote host closed the connection]
waterlink has quit [Ping timeout: 252 seconds]
waterlink1 has joined #crystal-lang
shama has joined #crystal-lang
leafybasil has joined #crystal-lang
shama has quit [Ping timeout: 250 seconds]
leafybasil has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
waterlink1 has quit [Ping timeout: 256 seconds]
leafybas_ has joined #crystal-lang
leafybasil has quit [Ping timeout: 240 seconds]
wanderer_ has joined #crystal-lang
blaix has joined #crystal-lang
shama has joined #crystal-lang
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven_ has joined #crystal-lang
Ven_ has quit [Client Quit]
shama has quit [Ping timeout: 265 seconds]
vegai has left #crystal-lang [#crystal-lang]
wanderer_ has quit [Quit: Page closed]
vikaton has joined #crystal-lang
leafybas_ has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
Ven_ has joined #crystal-lang
shama has joined #crystal-lang
shama has quit [Ping timeout: 256 seconds]
blaix has quit [Quit: Leaving.]
HakanD_ has joined #crystal-lang
shama has joined #crystal-lang
shama has quit [Ping timeout: 265 seconds]
kulelu88 has joined #crystal-lang
JBat has joined #crystal-lang
<jeromegn> I’m having trouble creating C bindings for a lib (libmongoc). i tried the two generator that exist without much success. It either didn’t work at all or produced odd code.
<jeromegn> I might need a tutorial or something, it can be more general… the thing is, I’m not sure what to Google to get that info
ismaelga has joined #crystal-lang
<jeromegn> yes
<jeromegn> I come from Ruby and other interpreted languages though. I’ve done some Go too! but I’m probably missing some basic knowledge about how things like that work in general
<jeromegn> that readme is a bit minimal :)
<jhass> I'm not sure what your question is though, do you have some specific ones?
<jeromegn> I can get some specific ones yes. how would that look as a lib in Crystal? https://github.com/mongodb/mongo-c-driver/blob/master/src/mongoc/mongoc-client.h#L65-L71
<jeromegn> struct MongocClientT; end ?
<jhass> you probably wouldn't map it
<jeromegn> are those what the Void and Void* are for?
<jhass> but typedef is an alias so to say
<jeromegn> interesting
<jeromegn> ah yea I see that now in the docs
<jhass> alias MongoClientT = ActualMongoClientT but you would just define the actual thing directly
<jhass> the alias is not useful in the binding
<jhass> or type, yeah
<jeromegn> so, this should be different? fun client_new = "mongoc_client_new"(uri_string : UInt8*) : MongocClientT*
<jeromegn> it should return something else than that MongocClientT?
<jeromegn> (thanks for bearing with me, I have very little experience with compiled languages)
<jhass> if you properly defined MongoClientT, that's fine
<jhass> if you never need to access the actual struct, but just obtain references to it and pass them elsewhere, it's easier to alias it to Void*
<jeromegn> interesting
<jhass> alias (or type) MongoClientT = Void*; fun ... : MongoClientT
<jhass> so that's if you never need to MongoClientT.new or client.some_field
<jhass> but solely pass pointers around
<jeromegn> but in any case, an empty struct would also work
<jhass> no
<jhass> well, only if you have only ever have pointers to it and don't allocate it yourself
<jhass> but it's still inferior to an alias then
<jhass> mongo_wants_a_client_t(MongoClientT.new) would fail since it wouldn't allocate enough memory
<jhass> with the empty struct
<jeromegn> ah
<jeromegn> that’s good to know
<jeromegn> seems safe to use a Void pointer, doesn’t look like it needs to allocate a new client
<jhass> yeah, having mongoc_client_new strongly hints that
shama has joined #crystal-lang
<jeromegn> :)
havenwood has joined #crystal-lang
<jeromegn> this is already making much more sense
<jhass> if you have a basic C usage example, I found it helps to try to translate it quite literally and bind only the stuff you need for it to work, to get started, IME
shama has quit [Ping timeout: 264 seconds]
<jeromegn> yea, I’m going to try that
<jeromegn> it seems like it always returns pointers
<jeromegn> if I want to get the actual value from the pointer in memory, how would I go about doing that?
<jeromegn> probably has nothing to do with c bindings at this point
<jeromegn> pointers seem mostly hidden in Crystal
<jhass> well, depends on what you mean with actual value
<jhass> Foo* is btw just syntax sugar for Pointer(Foo)
<jhass> so there's an actual Pointer class
<jeromegn> fun uri_get_string = "mongoc_uri_get_string"(uri : URI*) : UInt8*
<jeromegn> yes
<jeromegn> I want to get that string it’s returning a pointer of :)
<jhass> for UInt8* there's a String.new that takes it
<jeromegn> ohh
<jeromegn> well, I’ll be damned.
<jeromegn> also, is that normal? getting pointers to pointers? Pointer(Pointer(Void))@0x7FAF83D0F690
<kulelu88> is there a Dockerfile for crystal?
<jhass> jeromegn: mh, did you maybe do alias Foo = Void*; fun x() : Foo* ?
<jeromegn> yes
<jhass> jeromegn: while the original signature is like foo_t* ?
<jeromegn> I’m not certain
<jeromegn> I guess not
<jhass> it is
<jhass> C is weird
<jeromegn> the pointer star is on the function name it seems
<jhass> mongo_client_t *foo is the same as mongo_client_t* foo
<jhass> basically
<jhass> (there are always minor little differences with that stuff in C)
<jeromegn> so should I change something in my binding or is it normal that it returns a pointer of a pointer?
<kulelu88> that's what they've been saying since 1985 jhass =)
<jeromegn> I was born 1988!
<jhass> jeromegn: so, alias MongoClientT = Void* makes MongoClientT equal to Pointer(Void)
<jeromegn> right
<jeromegn> I should remove one of them stars somewhere eh? :)
<jhass> then fun mongo_client_new(...) : MongoClientT* makes MongoClientT* Pointer(Pointer(Void))
<jhass> yes ;)
<vikaton> is that in Lib C
<vikaton> or plain Crystal
<jeromegn> ok that works
<jeromegn> vikaton: C bindings in Crystal
<jeromegn> jhass: that works now :D https://gist.github.com/cd33ce428ba724693e01
<jhass> nice!
<vikaton> so fun mongo_client_new(...) : MongoClientT* makes MongoClientT* Pointer(Pointer(Void)) is C binding syntax in Crystal ?
<jeromegn> so I guess when creating c bindings, people generally make the api nicer than this :)
<jeromegn> not the “makes” bit.
kulelu88 has quit [Ping timeout: 252 seconds]
<jeromegn> ok this is great stuff
<vikaton> hmm
<vikaton> so in fun cos(value : Float64) : Float64, this calls the cos method in C ?
kulelu88 has joined #crystal-lang
<jeromegn> I believe so
<vikaton> >> sizeof(String)
<DeBot> vikaton: 4
<vikaton> >> sizeof(Void*)
<DeBot> vikaton: 4
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jhass> jeromegn: yes, they write wrappers, like class MongoClient; def initialize(url); @client = LibMongoC.client_new(url); end; def to_unsafe; @client; end; def uri; String.new(LibMongoC.client_get_uri(self)); end; end;
<jeromegn> nice
<jeromegn> I think that’s what I’ll do
<jeromegn> i work at Compose.io, we really love Ruby, but it’s been too slow for some of our stuff. due to its blocking nature...
<jeromegn> so I’m hoping with Crystal we can get the best of both worlds.
ponga has quit [Quit: Leaving...]
ponga has joined #crystal-lang
<vikaton> I can't execute C bindings D:
<vikaton> jeromegn: that would be nice!
<vikaton> >> lib C; fun cos(value : Float64) : Float64;end;C.cos(1.5)
<DeBot> vikaton: collect2: error: ld returned 1 exit status
<vikaton> hm ^ ?
<vikaton> I get the same error
<jhass> >> @[Link("m")];lib C; fun cos(value : Float64) : Float64;end;C.cos(1.5)
<DeBot> jhass: 0.0707372
leafybas_ has joined #crystal-lang
leafybasil has quit [Ping timeout: 264 seconds]
HakanD__ has joined #crystal-lang
shama has joined #crystal-lang
HakanD_ has quit [Ping timeout: 256 seconds]
shama has quit [Ping timeout: 256 seconds]
<vikaton> oh
Ven_ has joined #crystal-lang
<vikaton> what is"m" ?
<vikaton> C binding libs seem like interfaces
leafybas_ has quit [Read error: Connection reset by peer]
leafybasil has joined #crystal-lang
vikaton has quit []
<BlaXpirit> libm is glibs
<BlaXpirit> glibc
<jeromegn> jhass: got some more question(s). now I’m trying to create the bindings for libbson (BSON) and for some reason, MongoDB decided to put all those checks that raise “Only <bson.h> can be included directly.”
<jeromegn> I’m wondering if there’s a way around that. I removed the checks from a copy of the .h files, however that breaks for other reasons. I’m assuming the checks might have been important.
<jeromegn> I guess I might have to do that whole thing manually..
HakanD__ has quit [Read error: Connection reset by peer]
shama has joined #crystal-lang
HakanD__ has joined #crystal-lang
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
leafybasil has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
strcmp1 has quit [Ping timeout: 272 seconds]
HakanD___ has joined #crystal-lang
HakanD__ has quit [Ping timeout: 272 seconds]
strcmp1 has joined #crystal-lang
willlll has joined #crystal-lang
willlll has quit [Client Quit]
willlll has joined #crystal-lang
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<BlaXpirit> jeromegn, what about porting instead of wrapping
<jeromegn> you mean, writing a new driver and all?
<BlaXpirit> nvm, it's too bloated :|
<jeromegn> hehe
<jeromegn> it’s huge
<jeromegn> the C driver has all the features
<jeromegn> rewriting them seems wasteful
bcardiff has joined #crystal-lang
blaix has joined #crystal-lang
<jeromegn> so would: uint8_t hello[120] == StaticArray(UInt8, 120) ?
<jeromegn> >> ‘0’
<DeBot> jeromegn: Error in line 3: undefined local variable or method '‘0’'
leafybas_ has joined #crystal-lang
leafybasil has quit [Ping timeout: 252 seconds]
leafybas_ has quit [Ping timeout: 240 seconds]
<jeromegn> >> String.new(1_u8)
<DeBot> jeromegn: Error in line 3: no overload matches 'String::new' with types UInt8
<jeromegn> >> String.new(pointerof(1_u8))
<DeBot> jeromegn: Error in line 3: can't take address of 1_u8
ismaelga has quit [Remote host closed the connection]
<jhass> jeromegn: depends on what data you want to write there
<jeromegn> well
<jeromegn> the C thing populates a “char str[25]"
<jeromegn> so I pass it “str :: StaticArray(UInt8, 25)”
<jeromegn> and it populates it correctly, but then I don’t know how to get the string out of it
<jeromegn> hmm
<jhass> so you want a string, use a string
<jeromegn> a MongoDB ObjectID usually looks like “53sada245dss35sdfs3”
<jeromegn> “Converts oid into a hex encoded string."
<jeromegn> really?
<jhass> >> "53sada245dss35sdfs3".to_unsafe
<DeBot> jhass: Pointer(UInt8)@0x8052DEC
<jhass> mmh
<jeromegn> so even if the .h file specifies that this function wants an array of 25 char, I can tell it I’m going to send it a String? :)
<jhass> >> bytes :: UInt8[12]; bytes.class
<DeBot> jhass: StaticArray(UInt8, 12)
<jeromegn> nice shortcut
<jhass> >> lib Mongo; struct BsonOid; bytes :: UInt8[12]; end; end; Mongo::BsonOid.new
<DeBot> jhass: Syntax error in eval:3: expecting token ':', not '::'
<jhass> >> lib Mongo; struct BsonOid; bytes : UInt8[12]; end; end; Mongo::BsonOid.new
<DeBot> jhass: Mongo::BsonOid(@bytes=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
<jhass> depends on what you need really
<jeromegn> convert the hex representation to a string
<jeromegn> :)
<jeromegn> if I use Char, I get invalid values
<jeromegn> that’s what I get: [53, 53, 52, 56, 102, 57, 56, 49, 101, 101, 50, 101, 54, 49, 56, 53, 48, 56, 51, 102, 57, 50, 51, 49, 0]
<jhass> so that's just a bunch of bytes
<jhass> UInt8[] is sane
<jeromegn> right
<jeromegn> is there a way to convert these bytes to some value?
<jhass> sure
ismaelga has joined #crystal-lang
<jeromegn> basically a byte to utf8 conversion
<jhass> that doesn't make too much sense
<jhass> you need to specify what the conversion does
ismaelga has quit [Remote host closed the connection]
<jhass> >> [53, 53, 52, 56, 102, 57, 56, 49, 101, 101, 50, 101, 54, 49, 56, 53, 48, 56, 51, 102, 57, 50, 51, 49, 0].map {|byte| byte.to_s(16) }.join
<DeBot> jhass: "3535343866393831656532653631383530383366393233310"
<jhass> mh, no :P
ismaelga has joined #crystal-lang
<jhass> >> String.new [53, 53, 52, 56, 102, 57, 56, 49, 101, 101, 50, 101, 54, 49, 56, 53, 48, 56, 51, 102, 57, 50, 51, 49, 0].map(&.to_u8).to_unsafe
<DeBot> jhass: "5548f981ee2e6185083f9231"
<jeromegn> :o
<jeromegn> nice!
<jhass> but use the function libbson provides
<jeromegn> it provides ones? that bson_oid_to_string() gives me that array of bytes
ismaelga has quit [Remote host closed the connection]
strcmp1 has quit [Ping timeout: 240 seconds]
<jhass> String.new it
<jhass> fun bson_oid_to_string(oid : BsonOidT, str : UInt8*); str :: UInt8[25]; LibBson.oid_to_string(oid, str); String.new str
strcmp1 has joined #crystal-lang
<jeromegn> my program just exits with “Program terminated abnormally with error code: 11"
<jeromegn> which reminds me, I don’t know how to debug that
<jeromegn> no stack trace or anything
<jhass> try running it through valgrind
<jeromegn> I did modify the code a bit though
<jeromegn> if I use the exact thing you wrote, I get invalid voerload
<jeromegn> overload
<jeromegn> no overload matches 'String::new' with types StaticArray(UInt8, 25)
<jeromegn> which makes sense
<jeromegn> anyway, I can do it the long way for now
<jeromegn> not a big deal.
HakanD___ has quit [Quit: Be back later ...]
ismaelga has joined #crystal-lang
<jhass> jeromegn: if you have a UInt8 static array there's no need for the map
<jhass> just .to_unsafe it
<jeromegn> indeed
<jeromegn> nice
<jeromegn> dang, there’s no Time.new(seconds)
<jeromegn> had to jump around a lot
<jhass> >> Time.new(245)
<DeBot> jhass: 0001-01-01 00:00:00
<jhass> ?
<jhass> >> Time.new(10000000)
<DeBot> jhass: 0001-01-01 00:00:01
<jeromegn> it accepts ticks
<jeromegn> but not seconds
<jeromegn> time_t = LibBSON.oid_get_time(self)
<jeromegn> time_spec = LibC::TimeSpec.new
<jeromegn> time_spec.tv_sec = time_t
<jeromegn> time_spec.tv_nsec = time_t
<jeromegn> Time.new(time_spec)
<jeromegn> it also accepts a LibC::TimeSpec
<jhass> yeah, would be a good addition
<jhass> def self.at_epoch(seconds : Int)
<jeromegn> indeed
<jhass> wanna pull request it? ;)
<jeromegn> yea
<jeromegn> I’ll fork
Cidan is now known as zz_Cidan
<jhass> we got an open class model too btw, so I often just accumulate a bunch of core extensions while developing something to move on and upstream what I really use when done
<jeromegn> good idea
zz_Cidan is now known as Cidan
<jeromegn> so I don’t think the lines I pasted are right
<jeromegn> tv_nsec would be nano seconds I think.
<jhass> yeah
<jeromegn> yes
<jeromegn> that’s what I was basing my stuff on
<jhass> so at_epoch; new UnixEpoch + seconds.to_i64 * TimeSpan::TicksPerSecond, Kind::Utc, I think
<jeromegn> oh that’s interesting
<jhass> and while unix epoch is defined to be utc, some fail to do that, so might kind=Kind::Utc
JBat has quit [Quit: Textual IRC Client: http://www.textualapp.com/]
ponga has quit [Quit: Leaving...]
<jeromegn> yea that works
<jhass> lgtm, press the green button ;)
<jeromegn> nice
<jeromegn> done
<jeromegn> :)
<crystal-gh> [crystal] jeromegn opened pull request #629: Added `Time.at_epoch(seconds : Int, kind = Kind::Utc)` (master...time-at_epoch) http://git.io/vJycF
<jeromegn> exciting times with Crystal :D
<jeromegn> apparently, the libbson lib has macros in it that would simplify my life
<jeromegn> I wonder if I can bind to those
<jeromegn> I got a weird error
<jeromegn> Undefined symbols for architecture x86_64:
<jeromegn> "_BSON_APPEND_UTF8", referenced from:
<jeromegn> fun append_utf8 = "BSON_APPEND_UTF8"(doc : Document*, key : UInt8*, value : UInt8*) : Bool
<jhass> no, C macros are string replacements during compile time (actually in the preprocessor phase, so before compile)
<jeromegn> ah
<jeromegn> that’s alright I guess
<jeromegn> it’s not a huge deal
<jhass> you could only reimplement them in crystal macros or functions
waterlink has joined #crystal-lang
DerisiveLogic has joined #crystal-lang
HakanD___ has joined #crystal-lang
<jeromegn> can we have default args for `fun` in c bindings?
<jhass> I don't think so
<BlaXpirit> jeromegn, if it works, it works. if not, adding it is kinda controversial
<jeromegn> hehe
<jeromegn> it actually doesn’t make sense in my case, I was mostly curious.
<jeromegn> >> 0x00
<DeBot> jeromegn: 0
<jeromegn> >> 0x01
<DeBot> jeromegn: 1
<jeromegn> >> 0xFF
<DeBot> jeromegn: 255
<jeromegn> ah
aemadrid has quit [Quit: Connection closed for inactivity]
<jeromegn> >> (1 << 0)
<DeBot> jeromegn: 1
<jeromegn> >> (1 << 3)
<DeBot> jeromegn: 8
HakanD___ has quit [Quit: Be back later ...]
JBat has joined #crystal-lang
ismaelga has quit [Remote host closed the connection]
JBat has quit [Quit: Computer has gone to sleep.]
JBat has joined #crystal-lang
willlll has quit [Quit: willlll]
JBat has quit [Client Quit]
JBat has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
JBat has quit [Remote host closed the connection]
ismaelga has joined #crystal-lang
JBat has joined #crystal-lang
DerisiveLogic has quit [Ping timeout: 256 seconds]
<fowl> BlaXpirit: am I reading crsfml right, you declare types like type CircleShape = Void* and then open them with class to define methods? Or are those classes wrappers
<BlaXpirit> fowl, _lib files are one thing
<BlaXpirit> and the rest is a different thing
<BlaXpirit> however.
<fowl> I saw the Wrapper module
<BlaXpirit> i don't even know how to explain
<fowl> :p I'm trying to make sdl2 wrapper have that aww nice oop feel
<BlaXpirit> why do you insist on sdl2?
<BlaXpirit> i seriously don't get why people don't just use sfml
<jhass> that's easy: "there this stuff that does stuff and there's this other stuff that does other stuff and they together form that staff"
<fowl> Sfml only recently supports android ios
<BlaXpirit> gonna support them earlier than crystal :|
<jhass> mmh, googles adventure to port Dart to android could expose interesting APIs
bcardiff has joined #crystal-lang
<fowl> It wouldn't be hard for crystal to run on android..I'm not volunteering for it tho
<BlaXpirit> so you haven't provided arguments :|
<fowl> I have a c++ compiler with sdl2 on my phone
<BlaXpirit> could you please just use sfml? that would make me happy :D
<fowl> BlaXpirit: arguments for sdl2? I don't have any other than portability. I won't be using the drawing APIs
<BlaXpirit> what else then?
<BlaXpirit> it's not like there is a proper GL wrapper either
<jhass> don't we have like 3 sdl2 bindings already? you people should join efforts ;P
<fowl> There is
<BlaXpirit> have you tried to use it?
<fowl> The SOIL stuff crashes for me
<fowl> Other than that it works
leafybasil has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
bcardiff has joined #crystal-lang
bcardiff1 has joined #crystal-lang
bcardiff has quit [Read error: Connection reset by peer]
<fowl> jhass: I'm not trying to split them up more, I only found 2 recent looking repos tho and one points to the other one
<jhass> mh
<BlaXpirit> fowl, so do you want me to try again to explain?
<BlaXpirit> lib files just define a low level wrapper, they're very consistent and easy to understand
<fowl> BlaXpirit: can you explain @owned? How are destructors wired up
<BlaXpirit> then there are _lib files and suffixless files
<BlaXpirit> the only difference between them is that one is generated one is manually written
<BlaXpirit> but they must be considered together as a whole
<BlaXpirit> wait i mean
<BlaXpirit> _obj and suffixless
<BlaXpirit> sory
<BlaXpirit> so. remember like in nim we wrap some of CSFML's stuff as object, and some as ptr object
<BlaXpirit> so small objects are just structs here
<BlaXpirit> i do NOT wrap them. but I reopen the things that are defined in lib
<BlaXpirit> and just alias it
<BlaXpirit> then there are analogs of ptr objects - those that have Create and Destroy
<BlaXpirit> I wrap those ones in classes
<fowl> Where is @owned used to decide if the ptr should be destroyed
<fowl> Ah ok
<BlaXpirit> so. when I Create a CSFML object, i write @owned = true
<BlaXpirit> the finalizer just checks if it is @owned
<BlaXpirit> dup also creates new objects, so @owned is set to true there too
<fowl> When do you not own a ptr from sfml
<BlaXpirit> I pretty much just check if the function name has "create" or "copy" in it - then it's owned
<BlaXpirit> otherwise it's just for temporary use
<BlaXpirit> and instead of writing @owned = true transfer_ptr does it
<fowl> Yea
<BlaXpirit> especially because dup/copy doesn't have access to @owned
<fowl> Thanks for the explanation
<crystal-gh> [crystal] yyyc514 opened pull request #631: Fixes to StringFormatter (master...string_formatter) http://git.io/vJS9S
<Dreamer3> ok just need to maek sure all the other tests still pass
BlaXpirit has quit [Quit: Quit Konversation]
blaix has quit [Quit: Leaving.]
kulelu88 has quit [Ping timeout: 255 seconds]
<jeromegn> anybody know why I’d have to specify the type of return value in a Proc *only* when I do a string interpolation?
<jeromegn> -> (x : Hash(String, String)){ “hello” } works, but -> (x : Hash(String, String)){ “hello #{x[“name”]}” } complains that I need to us “as” to specify the return type.
<jeromegn> that example looks weird probably… this is in the context of a method that accepts a Proc with specific return values
bcardiff1 has quit [Quit: Leaving.]
<Dreamer3> what does it think th return type is?
<jeromegn> it doesn<t
<jeromegn> it points me to a page at the wiki
<jeromegn> it can’t infer the type
<jhass> it's probably because x["name"] may raise so it get's typed as String|NoReturn and then that isn't correctly handled or something like that
<jhass> I have a few similar bugs, having to do Pointer(Void).null where I don't care about the return value
<jeromegn> ah, nice
<jeromegn> didn’t know NoReturn was a thing
<jeromegn> does it exist? can’t find it in the api docs
<jeromegn> I noticed something interesting doing my C binding stuff… I lost the reference to my pointer at some point after calling a specific metho
<jeromegn> d
<jhass> it's a special compiler type
<jhass> >> def foo; raise "foo"; end; typeof(foo)
<DeBot> jhass: Sorry, that took too long.
<jhass> >> def foo; raise "foo"; end; typeof(foo)
<DeBot> jhass: NoReturn
<jeromegn> and I can specify it in my method?
willlll has joined #crystal-lang
<jeromegn> String | NoReturn
<jhass> never tried and doubt it
<jeromegn> ah
<jeromegn> >> def hello(proc : Proc(NoReturn)); proc.call; end; hello -> { raise “foo” }
<DeBot> jeromegn: Error in line 3: undefined local variable or method '“foo”'
<jeromegn> >> def hello(proc : Proc(String, String | NoReturn)); proc.call; end; hello -> (x : String) { return “ah #{x}” }
<DeBot> jeromegn: Syntax error in eval:4: expecting token '}', not 'end'
<jeromegn> >> def hello(proc : Proc(String, String | NoReturn)); proc.call; end; hello do |x|; return “ah #{x}”; end
<DeBot> jeromegn: Syntax error in eval:7: expecting identifier 'end', not 'EOF'
<jeromegn> ok well, I’ll work with that locally hehe
strcmp2 has joined #crystal-lang
strcmp1 has quit [Ping timeout: 252 seconds]
<crystal-gh> [crystal] asterite pushed 4 new commits to master: http://git.io/vJ9mc
<crystal-gh> crystal/master e4e72a0 Josh Goebel: formatting type should be generic...
<crystal-gh> crystal/master 9a62674 Josh Goebel: [strings] support "%X" and "%x" properly...
<crystal-gh> crystal/master 0a452ef Josh Goebel: [string] %i and %d should have same behavior...
<crystal-gh> [crystal] will closed pull request #627: Try, but fail, to reorder structs (master...failed-attempt-to-reorder-structs) http://git.io/vJif2
<Dreamer3> nice :)
<jeromegn> anybody knows how to translate this to a c binding in Crystal? http://api.mongodb.org/libbson/current/bson_value_t.html
<jeromegn> I wonder if we can nest union and struct like that
<jeromegn> attempting!
<jhass> jeromegn: uh, well, again, do you need to?
<jeromegn> not sure yet
<jeromegn> I made the basic struct
ismaelga has quit [Remote host closed the connection]
<jeromegn> which gives me the type
<jeromegn> I’ll see soon enough
<travis-ci> manastech/crystal#2298 (master - 69a19c0 : Ary Borenszweig): The build is still failing.
<jeromegn> jhass: apprently it’s necessary :( I’m trying to get a value from the BSON document. I need to define that struct properly to know which type of value it is.
<jeromegn> at least, I think.
<crystal-gh> [crystal] asterite pushed 5 new commits to master: http://git.io/vJ98d
<crystal-gh> crystal/master a45d1d6 Ary Borenszweig: Added some docs
<crystal-gh> crystal/master 47efdda Ary Borenszweig: Added `upcase` option to `Int#to_s`. Fixes #623
<crystal-gh> crystal/master fb6e50b Ary Borenszweig: Fixed #628: wrong parsing of `a.b/2`
<crystal-gh> [crystal] asterite pushed 3 new commits to master: http://git.io/vJ94q
<crystal-gh> crystal/master 734e33a Jerome Gravel-Niquet: Added `Time.at_epoch(seconds : Int, kind = Kind::Utc)`...
<crystal-gh> crystal/master a83a881 Jerome Gravel-Niquet: renamed at_epoch to at
<crystal-gh> crystal/master 6db38b6 Ary Borenszweig: Merge pull request #629 from jeromegn/time-at_epoch...
<jeromegn> hotness ^
<crystal-gh> [crystal] asterite closed pull request #626: Int@to_s should return only lowercase "digits" (master...lowercase_hex_int_to_s) http://git.io/vJ65N
<crystal-gh> [crystal] asterite closed pull request #625: macro should support string concat (master...macro_support_string_concat) http://git.io/vJ6QV
ismaelga has joined #crystal-lang
waterlink has quit [Ping timeout: 246 seconds]
ismaelga has quit [Ping timeout: 264 seconds]
<travis-ci> manastech/crystal#2301 (master - 6db38b6 : Ary Borenszweig): The build is still failing.
DerisiveLogic has joined #crystal-lang
DerisiveLogic has quit [Remote host closed the connection]
<travis-ci> manastech/crystal#2300 (master - 50dcb5f : Ary Borenszweig): The build is still failing.
<travis-ci> manastech/crystal#2302 (master - fdb2392 : Ary Borenszweig): The build is still failing.
<jeromegn> >> 0x7F
<DeBot> jeromegn: 127