ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.22.0 | Fund Crystal's development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
<hightower2> I have the code for it somewhere, will submit to the Benchmark module
Disrecollection has quit [Ping timeout: 240 seconds]
jhpratt has joined #crystal-lang
jhpratt has quit [Quit: Page closed]
<hightower2> I'm missing the Array#inject method
<FromGitter> <bigtunacan> @hightower2 you are looking for map
<hightower2> Yes and no, .inject is not the same - it keeps an implicit "accumulator" for the final value, and the result is that value rather than an array of elements
<FromGitter> <bigtunacan> Lol, yeah I just realized that
<FromGitter> <bigtunacan> I was thinking it was an alias for map, but it's an alias for reduce
<FromGitter> <bigtunacan> Which I don't see reduce defined on Array either
<hightower2> oh indeed, great
<FromGitter> <bigtunacan> Ah reduce is there
<FromGitter> <bigtunacan> Looks like it was inherited from Enumerable
<FromGitter> <bigtunacan> The General approach of Crystal is to not use a bunch of aliases with in the class, but two instead choose a single method name to reduce mental model.
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vHDCv
<crystal-gh> crystal/master 4a9b867 Ary Borenszweig: Array: fix some bugs in #fill. Fixes #4539
<travis-ci> crystal-lang/crystal#4a9b867 (master - Array: fix some bugs in #fill. Fixes #4539): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/241411952
<DeBot> https://github.com/crystal-lang/crystal/issues/4539 (Array#fill may result in an invalid memory access when given a negative argument.)
<FromGitter> <faultyserver> @bigtunacan I don't know how far you've gotten with the theory, but I've started writing up an introduction to compilers for a (currently) fictional language: https://github.com/myst-lang/myst/blob/master/COMPILERS_INTRO.md. It goes through some small examples of each step of a dynamic language compiler (lexing, parsing, visiting, and a VM), trying to help bridge the gap between the purely-theoretical side
<FromGitter> ... of compilers in most books today and real, practical compilers in the world today.
<FromGitter> <faultyserver> disclaimer: I don't claim to know everything about compilers, I just got annoyed that I couldn't find any good examples of anything other than a tree-walking compiler, which is pretty much useless in the real world
<FromGitter> <faultyserver> Charly lang (https://github.com/charly-lang/charly/blob/master/src/charly/syntax/parser.cr) is also a good example of a compiler that hasn't grown too much
<FromGitter> <faultyserver> I'm also just starting the implementation of that (currently) fictional language, so it could be interesting to watch how it grows from nothing to something basic?
Raimondi has quit [Ping timeout: 268 seconds]
red_menace has joined #crystal-lang
red_menace has left #crystal-lang [#crystal-lang]
Raimondi has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
_whitelogger has joined #crystal-lang
Raimondi has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondi has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
red_menace has joined #crystal-lang
rohitpaulk has quit [Read error: Connection reset by peer]
Disrecollection has joined #crystal-lang
Disrecollection has quit [Remote host closed the connection]
_whitelogger has joined #crystal-lang
Raimondi has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
<hightower2> Does crystal have "automatic" variable inside blocks, like 'it' in Groovy?
<FromGitter> <sdogruyol> nope
<hightower2> Have some weird issue. I do p myvars.map{|x|x.class} to confirm I am using all Float64s. Then I call another function with those vars (and perform the same p to make sure they're still Float64s). Then I subtract two of them there, and get: Couldn't find overloads for these types: - Float64#-(String)
<FromGitter> <sdogruyol> code please
<hightower2> Yeah, trying to come up with a usable isolated paset
<hightower2> paste*
<hightower2> It is only the final step of the problem, I need to work on isolating the code before
<hightower2> But this is the final 3 lines that give me trouble
Raimondi has joined #crystal-lang
<FromGitter> <mverzilli> that generally means at some point of your program `current_average` is assigned a String
<hightower2> verzilli right of course, but these 3 lines execute directly in the order shown. They report their class as Float64, and immediately in the next line I do a subtract and get this error.
<FromGitter> <mverzilli> without seeing a little more code is hard to tell. it could be a bug in Crystal's "class" method
<hightower2> I am working on trying to come up with an isolated example
Raimondi has quit [Ping timeout: 268 seconds]
<FromGitter> <mverzilli> oh, wait
<FromGitter> <mverzilli> "class" returns the runtime class
<FromGitter> <mverzilli> run this and see what happens
<FromGitter> <mverzilli> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=593bb06c02c480e6722daacb]
<hightower2> It reports: (Float64 | Int32 | String) for both variables
<FromGitter> <mverzilli> `current_average.class` should be returning `String`
<FromGitter> <mverzilli> while `typeof(current_average` should be `Float64 | String`
<FromGitter> <mverzilli> are you running the exact code snippet I pasted here?
<hightower2> These values are coming from a text file, and I produce them using: File.read( "test.txt").split(' ').map{ |value| value.to_f}
<FromGitter> <mverzilli> right, I just produced a snippet to explain what's happening
<hightower2> mverzilli oh no, I added typeof() to my code and reported that. The one you pasted, if ran exactly as you gave it, works like you report
<FromGitter> <mverzilli> cool, that is to show the difference between typeof and class
<FromGitter> <mverzilli> for the compiler, current_average might be a String or a Float64
<FromGitter> <mverzilli> so it can't let you run `-`, because there's no way to subtract a String from a Float
<crystal-gh> [crystal] ujifgc opened pull request #4540: add HTTP::STATUS_CODES, use official IANA Registry (master...http-status) https://git.io/vHD2O
<hightower2> How does it figure out it can be a string when it is produced as a result of string.to_f ?
<FromGitter> <mverzilli> `class` returns `Float64` because that's what it is at runtime
<hightower2> and/or how to avoid that then?
<FromGitter> <mverzilli> to understand why it says it could be a string we would need to see more code
<FromGitter> <mverzilli> in general, you don't want to avoid that, what you want to do is find out where you might missing something... this is Crystal catching a potential bug for you
<hightower2> Right, sure, though the code is simple, don't see a problem. I'm going over it once again.
<hightower2> Btw, how do I "expand" an Array into list of arguments, e.g. if I have arr.size == 4, how do I call a method with 4 arguments? *arr doesn't seem to work.
<FromGitter> <mverzilli> you can do it with tuples, not with arrays AFAIK
<hightower2> oh wow, not only that worked, but it got rid of the Float64/String problem. Now I am returning {1,2,3,4} from my function, whereas previously I was returning [1,2,3,4]. And I call nextmethod(*tuple) now instead of nextmethod(arr[0],arr[1],arr[2],arr[3]) and that seems to work
<FromGitter> <mverzilli> nice, and as a bonus now you're removing some pressure from the GC :)
DeBot has quit [Ping timeout: 255 seconds]
DeBot has joined #crystal-lang
Raimondi has joined #crystal-lang
<hightower2> Hm, how can I run Benchmark.ips() without having it print anything to the screen? I don't see a way to prevent report() from being called.
Raimondi has quit [Ping timeout: 268 seconds]
dtcristo has joined #crystal-lang
<hightower2> Oh I see, by using Benchmark::Ips directly instead of via Benchmark.ips
Raimondi has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
DeBot has quit [Quit: Crystal IRC]
DeBot has joined #crystal-lang
<FromGitter> <ultra2mh> hi i have a problem can someone please help me
<FromGitter> <sdogruyol> hey
asterite has quit [Quit: Bye]
jhass has quit [Quit: Bye]
<FromGitter> <ultra2mh> im building app with kemal framework
<FromGitter> <ultra2mh> how should i use bootstrap.css in layout file ?
<FromGitter> <ultra2mh> i use file location directly but it dont load
<FromGitter> <sdogruyol> check this repo and code https://github.com/f/kemal-react-chat/blob/master/src/views/index.ecr#L8 @ultra2mh
red_menace has left #crystal-lang ["bye bye..."]
<FromGitter> <ultra2mh> thanks simple ...but im sure i use correct path for file but not load
<FromGitter> <sdogruyol> where's your file located
<FromGitter> <sdogruyol> under /public or /src/public?
<FromGitter> <ultra2mh> under src/public/css/
<FromGitter> <ultra2mh> i put bootstrap and style.css in latest folder "css"
<FromGitter> <sdogruyol> you should not put that in src
<FromGitter> <ultra2mh> what is correct path?
<FromGitter> <ultra2mh> where shoud i locate my css files
<FromGitter> <sdogruyol> public is a root folder just like src
<FromGitter> <ultra2mh> thankyou so much
<FromGitter> <ultra2mh> solved
<FromGitter> <sdogruyol> cool :+1:
_whitelogger has joined #crystal-lang
Raimondi has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
splitty__ has joined #crystal-lang
splitty_ has joined #crystal-lang
splitty___ has quit [Ping timeout: 240 seconds]
splitty__ has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
hightower4 has joined #crystal-lang
Raimondi has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
hightower3 has joined #crystal-lang
hightower2 has quit [Ping timeout: 240 seconds]
asterite has joined #crystal-lang
jhass has joined #crystal-lang
manveru_ is now known as manveru
rohitpaulk has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
Raimondi has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
hightower4 has quit [Ping timeout: 255 seconds]
Raimondi has joined #crystal-lang
<FromGitter> <domgetter> Is it possible to create a Linux kernel module with Crystal or does a crystal program depend on userspace stuff?
_whitelogger has joined #crystal-lang
<FromGitter> <mhsjlw> i guess you technically *could*...
<FromGitter> <mhsjlw> if there is a way to disable the standard library
<FromGitter> <mhsjlw> but to be honest i'd really just expose a C api from Crystal and write the kernel module itself in C
<FromGitter> <mhsjlw> @domgetter
hightower4 has joined #crystal-lang
fenicks has joined #crystal-lang
fenicks1 has joined #crystal-lang
fenicks has quit [Ping timeout: 255 seconds]
fenicks1 has left #crystal-lang [#crystal-lang]
dancinglightning has joined #crystal-lang
dancinglightning has left #crystal-lang [#crystal-lang]
rohitpaulk has quit [Ping timeout: 240 seconds]
<hightower4> How would I write a YAML.mapping() for Benchmark::IPS::Entry class? I have problems with 'action' which expects a block, and with all other properties that are required or must have non-null value.
<FromGitter> <bararchy> @domgetter some people have already created a whole Kernel with Crystal
<Papierkorb> RX14: Linux Kernel module in Crystal? Challenge accepted.
<FromGitter> <bew> ahahah
<Papierkorb> I however can predict the outcome: Yes it's possible, but it's not a practical idea
<Papierkorb> <mhsjlw> if there is a way to disable the standard library <- In fact you can by passing `--prelude empty` to the `build` command.
<Papierkorb> But it's a pain. The Int#/ implementation in the stdlib is not decoration, it is used and necessary if you need such fancy features such as integer division.
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 258 seconds]
<FromGitter> <bararchy> Well :) ⏎ ⏎ https://github.com/TheKernelCorp/NuummiteOS
<hightower4> I have: @archive = YAML.parse( File.read "yaml").as_h and I am getting: Can't infer the type of instance variable '@archive'
<hightower4> The YAML content corresponds to {} of String => Array(SomeClass), but I don't see where to specify that, since these types are incompatible with YAML::Any/YAML::Type or whatever YAML module does
<oprypin> @jwoertink, it looks like you're writing a game framework. any reason that you're passing up CrSFML? seems like you're reinventing a lot of what it has. oh and its tutorials would also give you basic examples for the game loop.
hightower2 has joined #crystal-lang
hightower4 has quit [Ping timeout: 240 seconds]
<Papierkorb> hightower2: Prefer `YAML.mapping` over `YAML.parse` if possible
<Papierkorb> hightower2: Crystal can't know that YAML::Any#as_h's hash will be compatible with your hash. In fact, `YAML.parse` can't know that it's an Array of `SomeClass`. You can do all this though `YAML.mapping` easily
<crystal-gh> [crystal] oprypin opened pull request #4542: Turn Random::System into a module (+docs) (master...random-module) https://git.io/vHyk6
<FromGitter> <jwoertink> @oprypin I started work on my framework before I saw CrSFML, and contributing to the SDL shard with @ysbaddaden has been a great learning experience for me.
livcd has quit [Ping timeout: 260 seconds]
livcd has joined #crystal-lang
<FromGitter> <bigtunacan> @jwoertink @oprypin For people that are already familiar with SDL or SFML some don't want to switch so having both supported seems good
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<hightower2> Papierkorb, I have trouble with non
<hightower2> ... with the object properties using YAML.mapping. For each property, it complains that it is not clear if it's a mistake or a property is nulable.
<hightower2> and also the class I want to map has a block as one of the required arguments in the constructor, and I didn't figure out what to do with that part.
<hightower2> And also what if my YAML isn't just that object, but e.g. an array of objects, or e.g. a Hash of Scalar => Array(SomeClass)