ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.29.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
daemonwrangler has joined #crystal-lang
<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> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d0ae18dfaf70031f9545a58]
<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> https://github.com/search?l=Crystal&q=language&type=Repositories doesnt seem right
<FromGitter> <watzon> Searching for `shard.yml` returns over 5000 results
<FromGitter> <watzon> I want to use those results and then filter based on whether the repo has releases
<FromGitter> <watzon> And a few other things
<FromGitter> <Blacksmoke16> gotcha
<FromGitter> <Blacksmoke16> and yea, my search doesnt include repos where main lang isnt crystal
<FromGitter> <watzon> About to start wrapping TDLib
<FromGitter> <watzon> Wish me luck
_whitelogger has joined #crystal-lang
laaron- has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <bew> .... Wishing you luck 🙏
<FromGitter> <vladfaust> Is it possible to compile Crystal into LLVM IR?
teardown has joined #crystal-lang
devil_tux has joined #crystal-lang
devil_tux has quit [Ping timeout: 258 seconds]
<FromGitter> <vladfaust> What a stupid question, of course it is
devil_tux has joined #crystal-lang
return0e has quit [Ping timeout: 245 seconds]
return0e has joined #crystal-lang
waheedi has joined #crystal-lang
flaviodesousa has joined #crystal-lang
waheedi has quit [Quit: waheedi]
waheedi has joined #crystal-lang
waheedi has quit [Client Quit]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
DTZUZO has quit [Ping timeout: 245 seconds]
devil_tux has quit [Ping timeout: 268 seconds]
flaviodesousa has quit [Quit: KVIrc 4.9.3 Aria http://www.kvirc.net/]
<FromGitter> <bew> `--emit llvm-ir`
<FromGitter> <bew> And you get the ir in `your_program.ll`
ua has quit [Ping timeout: 272 seconds]
ua has joined #crystal-lang
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/73c8 am i missing something?
<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> <asterite> Also read this: https://crystal-lang.org/reference/syntax_and_semantics/virtual_and_abstract_types.html (here `[Foo, Bar]` results in `Array(Parent)`) and the compiler assumes any concrete `Parent` could be passed there, including `Child`
<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 joined #crystal-lang
alex`` has quit [Ping timeout: 248 seconds]
alex`` has joined #crystal-lang
BaldEagleX02 has quit [*.net *.split]
Yxhuvud has quit [*.net *.split]
return0e has quit [Ping timeout: 245 seconds]
return0e has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron- has joined #crystal-lang
laaron- has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
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
<FromGitter> <Blacksmoke16> :thinking:
<FromGitter> <Blacksmoke16> whoa https://play.crystal-lang.org/#/r/73dz
<FromGitter> <watzon> https://carc.in/#/r/73e1
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/73e2
<FromGitter> <Blacksmoke16> neat
<FromGitter> <watzon> Generics just have to be constant at compile time
<FromGitter> <watzon> StaticArray actually does this
<pracabor> love it
<FromGitter> <Blacksmoke16> doesnt work with strings tho https://play.crystal-lang.org/#/r/73e4
<pracabor> I was asking because I was expecting to hear "no"
<FromGitter> <Blacksmoke16> hmm
<pracabor> I wouldn't be surprised to hear that string literals are treated differently than other literals, it's not uncommon
<FromGitter> <watzon> Hmm weird
<FromGitter> <watzon> Because strings are immutable
<FromGitter> <watzon> so you'd think
<FromGitter> <Blacksmoke16> numbers are only ones you can do, `nil`, or `true` dont work either
<FromGitter> <Blacksmoke16> ib4 its a bug that it works with numbers :P
<pracabor> yeah I was just thinking about that
<FromGitter> <watzon> I don't think so since `StaticArray` uses it
<FromGitter> <watzon> And that is a part of the stdlib
<pracabor> welp I'm going to write a bunch of code around this behavior
<FromGitter> <watzon> There must be a reason
<FromGitter> <Blacksmoke16> might be worth making a forum post about it
<FromGitter> <watzon> @asterite could probably tell us
<pracabor> ugh forums
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
greengriminal has joined #crystal-lang
RyanMcCoskrie has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
lucasb has quit [Quit: Connection closed for inactivity]
<FromGitter> <bew> I think thame fact that it works with numbers is just an edge case in the generic type system to have it in StaticArray
<FromGitter> <bew> thame > the
duane has quit [Ping timeout: 244 seconds]
greengriminal has joined #crystal-lang
RyanMcCoskrie has quit [Ping timeout: 272 seconds]
alex`` has quit [Ping timeout: 246 seconds]
alex`` has joined #crystal-lang
go|dfish has quit [Ping timeout: 245 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
gangstacat has quit [Ping timeout: 258 seconds]
gangstacat has joined #crystal-lang
Dreamer3 has joined #crystal-lang
Dreamer3 has quit [Quit: Computer has gone to sleep.]
DTZUZO has joined #crystal-lang