<FromGitter>
<Blacksmoke16> whats with the forums? `This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.`
<FromGitter>
<Blacksmoke16> why does a blob in sqlite db driver return a String?
<FromGitter>
<Blacksmoke16> i guess it just reads it as whatever is in it
<FromGitter>
<watzon> It returns it as a string no matter what though? Wouldn't Bytes make more sense?
<FromGitter>
<Blacksmoke16> no i mean if i do like
<FromGitter>
<Blacksmoke16> `SQLite3::ResultSet#read returned a String. A Slice(UInt8)`
<FromGitter>
<Blacksmoke16> but if you change `30` to like `"foo"`
<FromGitter>
<Blacksmoke16> `SQLite3::ResultSet#read returned a Int64. A Slice(UInt8) was expected. (Exception)`
<FromGitter>
<Blacksmoke16> but if you change the `30` to like `"foo"`
<FromGitter>
<Blacksmoke16> `SQLite3::ResultSet#read returned a String. A Slice(UInt8)`
<FromGitter>
<watzon> Hmm weird
<FromGitter>
<Blacksmoke16> should be returning `Bytes` no matter the type thats in the column
<FromGitter>
<watzon> Yeah I agree
<FromGitter>
<Blacksmoke16> I made an issue for it
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter>
<watzon> Hmm what would be a good way to split a time span into blocks? Say I have a span from January 1st, 2013 to now and I want to split it into one month blocks.
<FromGitter>
<watzon> Maybe I'm thinking about this the wrong way
greengriminal has joined #crystal-lang
<FromGitter>
<Blacksmoke16> What's the end goal
<FromGitter>
<watzon> Well the github API limits searches to 1000 results, but you can bypass that by limiting your searches to specific time windows. I'm trying to fetch every repository with a `shard.yml` file, which is over 1000 so I need to break the search up.
<FromGitter>
<Blacksmoke16> define the time outside a loop
<FromGitter>
<Blacksmoke16> then end of each iteration time = time + 1.month?
<FromGitter>
<Blacksmoke16> im pretty sure there isnt much more than a few 1000 crystal libs
<FromGitter>
<Blacksmoke16> ah looks like you have to rewind first?
<FromGitter>
<Yashko> Hey guys, i'm new to Crystal and never tried Ruby (: Trying to build websocket server without external libs, is there an example of it using only stdlib?
devil_tux has joined #crystal-lang
duane has joined #crystal-lang
alex`` has quit [Ping timeout: 272 seconds]
alex`` has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter>
<naqvis> I’m trying to achieve `interface` like functionality by using `modules`, but experiencing problem due to compiler enforce `virtual types`.
ua has quit [Ping timeout: 246 seconds]
ua has joined #crystal-lang
<FromGitter>
<naqvis> any pointers on how to achieve `interface` would be highly appreciated
<FromGitter>
<j8r> you can look at `abstract` methods
<FromGitter>
<naqvis> yeah I did
<FromGitter>
<naqvis> by using modules, I was referring to the point to defining `abstract` methods in modules and `include` them in respective classes
lucasb has joined #crystal-lang
<FromGitter>
<naqvis> and by `interface` i mean what they are called `interface`, `protocols` in other languages. I mean a class implementing a set of defined functionality *without* doing direct inheritence
<FromGitter>
<j8r> by including a module, you do composition
<FromGitter>
<naqvis> true, so I said trying to achieve `interface` like functionality, as per my understanding Crystal doesn’t have `interface` functionality
<FromGitter>
<j8r> yes, module is the closer you can get
<FromGitter>
<naqvis> let me try to put some contrived example on playground, to explain what i'm experiencing
<FromGitter>
<asterite> The compiler considers the case of Child too. What if you pass `Child.new`? Is Child something you want to create? If not, make it `abstract` (same with `Parent`) and the code should compile
<FromGitter>
<naqvis> Thanks, but that restricts to inheritence approach. My question is, do we have any mechanism to achieve `interface` like functionality? As you can see in my use case, only Foo and Bar are the one’s which comply with Interface, and I needn’t to force that to parent level
<FromGitter>
<asterite> Actually...
<FromGitter>
<naqvis> and those instances are passed with Interface type annotated, that will ensure that anything that get passed will comply with that protocol
<FromGitter>
<naqvis> and object not matching annotated type shouldn't be able to pass compiler
<FromGitter>
<asterite> what I said is a bit wrong, I see you do `.as(Intf)` and so that tells the compiler that makes it be `Foo | Bar`, which results in `Child` (according to the link I gave you)
<FromGitter>
<asterite> The compiler won't create a union of `Foo | Bar` if both types are under the same class hierarchy to avoid some performance issues during compilation. It will treat them as `Child` or any of its subclasses
<FromGitter>
<asterite> Should `Child` be instantiated at all?
<FromGitter>
<asterite> But... to reply to you: no, there's no notion of `interface` in Crystal
<FromGitter>
<asterite> that's a pretty big hole in the type system that I hope we'll eventually fix
<FromGitter>
<asterite> but you can use `module` for now
<FromGitter>
<naqvis> Thank you @asterite , I read the reference material, but was hoping to see if there are some better alternatives
<FromGitter>
<asterite> In your example you could probably make `Child` and `Parent` be modules too, I don't quite understand why they need to be classes (what they add to the hierarchy). Then your code will also work fine
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter>
<naqvis> This is contrived example, in my real use-case both parents are real classes with functionality and can be instantiated on their own. Child classes are the one's with extra functionality
gangstacat has quit [Ping timeout: 258 seconds]
gangstacat has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
ua has quit [Ping timeout: 272 seconds]
ua has joined #crystal-lang
<pracabor>
Is it possible to pass a parameter to a generic class that is not a Type, but an instance of a Type?
<FromGitter>
<Blacksmoke16> like `Array(MyType.new)`?
<pracabor>
For example, could I have a generic class which accepts "2" as the generic parameter?
<pracabor>
I'm looking at implementing a bunch of math at compile time to optimize some calculations, and it'd be handy to be able to parameterize that
<FromGitter>
<watzon> I believe so
<FromGitter>
<watzon> I actually know so
<FromGitter>
<watzon> When it comes to numbers anyway
<pracabor>
cool, do you have an example you can link to?
<FromGitter>
<Blacksmoke16> if you do like `class MyClass(T)` you can just do like `MyClass.new 2 and it infers the type
<FromGitter>
<watzon> Generics just have to be constants I believe. It could accept 2, but not a var that has a value of 2