RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.20.1 | 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
<Papierkorb> My desk is full of those. Work discourages using stickies, but they don't provide any other tool, so stickies it is there too.
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <fridgerator> nah, I usually make notes in markdown files
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 250 seconds]
ome has joined #crystal-lang
<wmoxam> I've got plenty of ideas stuck in Asana :p
<crystal-gh> [crystal] asterite closed pull request #3697: Remove dot segments in uri path as per RFC 3986 6.2.2.3 (master...remove-dot-segments-in-uri-path) https://github.com/crystal-lang/crystal/pull/3697
<crystal-gh> [crystal] asterite pushed 3 new commits to master: https://github.com/crystal-lang/crystal/compare/25c4ae17fd3d...39ffa702cbd7
<crystal-gh> crystal/master 39ffa70 TSUYUSATO Kitsune: Add spec for #<loc:push> and #<loc:pop>
<crystal-gh> crystal/master 484f365 TSUYUSATO Kitsune: Refactor and rename #<loc:save> and #<loc:reset> to #<loc:push> and #<loc:pop>
<crystal-gh> crystal/master d1bd2a7 TSUYUSATO Kitsune: Reset location after block yielding in macro expansion...
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 250 seconds]
<travis-ci> crystal-lang/crystal#25c4ae1 (master - Add URI#normalize: remove dot segments in uri path as per RFC 3986 6.2.2.3 (#3697)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/186237359
<DeBot> https://github.com/crystal-lang/crystal/pull/3697 (Remove dot segments in uri path as per RFC 3986 6.2.2.3)
<travis-ci> crystal-lang/crystal#39ffa70 (master - Add spec for #<loc:push> and #<loc:pop>): The build was broken. https://travis-ci.org/crystal-lang/crystal/builds/186237943
pawnbox has joined #crystal-lang
<crystal-gh> [crystal] bmulvihill opened pull request #3754: Add String#each_split(Char) (master...each-split) https://github.com/crystal-lang/crystal/pull/3754
<crystal-gh> [crystal] petehuang closed pull request #3752: Improve docs to require equal length size (master...patch-1) https://github.com/crystal-lang/crystal/pull/3752
vikaton has quit [Quit: Connection closed for inactivity]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<travis-ci> crystal-lang/crystal#39ffa70 (master - Add spec for #<loc:push> and #<loc:pop>): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/186237943
<FromGitter> <spalladino> @RX14 we got a spreadsheet with the issue categories from other communities, and a few candidate changes for crystal
<FromGitter> <spalladino> We'll be probably be settling for an issue categorising scheme soon, and publish it
<FromGitter> <spalladino> Next step will be to draw straws to see who gets to tag or re-tag everything :-P
<FromGitter> <spalladino> And actually, one of the categories is shard-idea, so you could drop your ideas on the issue tracker and have other people join; though I'm unsure if the tracker is the best place for that collaboration
<FromGitter> <spalladino> cc @petehuang
ome has quit [Quit: Connection closed for inactivity]
<FromGitter> <petehuang> @spalladino put me in coach! i'm so far away from being able to contribute technically but i would love to do whatever i can to enable this community to focus on doing its best work
dtzu has quit [Quit: WeeChat 1.4]
vivus-ignis has joined #crystal-lang
bjz has joined #crystal-lang
pawnbox has quit [Ping timeout: 258 seconds]
pawnbox has joined #crystal-lang
matp has quit [Remote host closed the connection]
matp has joined #crystal-lang
Raimondi has quit [Read error: Connection reset by peer]
Raimondi has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
olek_poz has joined #crystal-lang
<aurelien> Yesterday splitty_ says: <splitty_> I'm writing a kernel in Crystal
<aurelien> what would be the interest of doing that? more efficiency? better hardware integration? ??
<jsaak> i guess learning, or dreams
soveran has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 244 seconds]
Raimondii is now known as Raimondi
[sleep]splitty_ is now known as splitty_
<splitty_> aurelien, I've written several kernels in C, Assembly, Rust, and even C# with a custom compiler.
<splitty_> Writing kernels in C isn't fun, writing kernels in Assembly is fun but you can only get so far before going crazy
<splitty_> Rust is a pretty nice language for writing kernels, and Crystal is just pure awesome
<splitty_> I'm doing it to learn, and because OS dev is generally fun
<splitty_> You learn so much about how the parts of the computer actually work under the hood
<aurelien> splitty_: sounds cool
vivus-ignis1 has joined #crystal-lang
Raimondii has joined #crystal-lang
soveran has quit [Remote host closed the connection]
vivus-ignis has quit [Ping timeout: 260 seconds]
vivus-ignis1 is now known as vivus-ignis
Raimondi has quit [Ping timeout: 244 seconds]
Raimondii is now known as Raimondi
<splitty_> crystal tool format is strange
<splitty_> It reformats the following:
<splitty_> asm("inl $1, $0" : "={eax}"(result) : "{dx}"(port) :: "volatile")
<splitty_> To this:
<splitty_> asm("inl $1, $0" : "={eax}"(result) : "{dx}"(port):: "volatile")
<Yxhuvud> Hmm, I'm not certain how much love the assembler parts of it has gotten yet:)
vivus-ignis1 has joined #crystal-lang
<splitty_> I just reverted that specific part. It's probably gonna improve in the future ^^
vivus-ignis has quit [Ping timeout: 250 seconds]
vivus-ignis1 is now known as vivus-ignis
<Yxhuvud> Probably. Especially if it is reported as an issue.
<olek_poz> When i override a method, how can i run the previous one within overiden?
<Yxhuvud> super
olek_poz is now known as akwiatkowski
<FromGitter> <radarek> Hello everybody!
<FromGitter> <sdogruyol> @radarek hey
<Yxhuvud> Ah, no inheritance involved. Then you don't. Unless it has arguments of different types.
<Yxhuvud> I'd assume that you can also define the method in a module that you then include, to make it work with super, but I havn't actually tested that in crystal
<FromGitter> <radarek> Btw, what do you think about monkey-patching in Crystal context? I have a feeling that it shouldn'e exist in crystal.
<FromGitter> <radarek> I've been programming in Ruby since 2008 and beside first excitement I don't see any good reason to support monkey patching. It usually ends up with bugs & hidden problems.
<FromGitter> <radarek> I'm only talking about overwriting existing method, adding new one is let say okeish.
<splitty_> Yxhuvud, should I submit the format tool bugs to the Crystal repository or is there a special place for that?
<Yxhuvud> I've submitted issues to the normal one before. It has a special tag that it will get
<akwiatkowski> I try to be practical and unfortunately monkey approach is easier in my case.
<akwiatkowski> Example. I'm writing blog engine and the core library is regular blog. But my blog posts has some additional features like tags (yep, it is standard), pois, geographic lands, towns, ... some other variables.
<FromGitter> <radarek> <akwiatkowski> so do you require your blog engine library and overwrite some methods?
<akwiatkowski> It's much easier to monkey patch and add method only related to theese not standard post attributes than to enforce lib user to intherit Blog, PostCollection and Post class. Probably using Blog(T) approach could be ok, but at this moment it's too big refactor.
<akwiatkowski> Yes. I know it's not the best moral solution.
<akwiatkowski> Post initialize title, image url, ... standard variables in lib, and there is method `initialize_custom` which is overriden and there I initialize all custom code (pois, lands, towns, ...)
<FromGitter> <radarek> Yeah, it is a little bit strange for me. I've always used MP as a last resort.
<akwiatkowski> Suggestions are welcome
<akwiatkowski> But I'm not doing Blog(T) approach at this moment
<FromGitter> <radarek> <akwiatkowski> Maybe you could share some excerpt from your engine? At least example showing your base class and how it's later monkey patched in specific scenarion.
<akwiatkowski> radarek: I'm happy to do it, just finish this commit and then https://github.com/akwiatkowski/tremolite/tree/lib_refactor I'm writing blog engine for me and current part is to refactor it - separate custom things
soveran has joined #crystal-lang
vivus-ignis has quit [Remote host closed the connection]
soveran has quit [Ping timeout: 256 seconds]
<FromGitter> <radarek> Does `data`directory contain example app that uses your blog engine?
<akwiatkowski> radarek: yes
Philpax has joined #crystal-lang
<akwiatkowski> note: text content is in Polish and everything is work in progress. `data` will be removed from this repo when ready.
bjz has joined #crystal-lang
<FromGitter> <radarek> <akwiatkowski> Is there any advantage doing it that way instead of just using inheritance?
<FromGitter> <radarek> I don't mind that it's Polish because I'm from Poland :D.
<akwiatkowski> End user doesn't have to write or modify classes like Blog or PostCollection to use Array(CustomizedPost)
<FromGitter> <radarek> Yeah, right.
<akwiatkowski> I know it is possible to use Blog(T) style, but I could check this later
<akwiatkowski> That would look too much hackish
<akwiatkowski> It will scare most users. "Man, I'm not using generic types, I just wanted to add one field to post"
<FromGitter> <radarek> Ok, so this kind of MP is in my standards acceptable one. You overwrite existing method but it's original implementation is empty. It's kind of Template Method pattern.
<FromGitter> <radarek> What I worry about is using MP for overwriting existing methods in classes we don't own. I can even give example when it ends up with segfault.
<akwiatkowski> It's quite easy to end with segfault
<FromGitter> <radarek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=585d07f9c02c1a3959a3bebf]
<FromGitter> <radarek> Running it ends with segfault.
<yopp> hey. stupid questions. is there any other memory metrics, apart of GC.stats?
<akwiatkowski> radarek: That's a bit brutal example :)
vivus-ignis has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
<akwiatkowski> yopp: Without using system commands?
soveran has quit [Remote host closed the connection]
<akwiatkowski> https://github.com/ysbaddaden/posix maybe this will help you integrate with system without running commands
<FromGitter> <asterite> Yxhuvud try previous_def instead of super
<yopp> akwiatkowski, ah, right. Thanks!
<yopp> Magic world of posix.1 in linux: getrusage The above struct [rusage] was taken from BSD 4.3 Reno. Not all fields are meaningful under Linux. Right now (Linux 2.4, 2.6) only the fields ru_utime, ru_stime, ru_minflt, ru_majflt, and ru_nswap are maintained.
<yopp> ¯\_(ツ)_/¯
<Yxhuvud> asterite: well it wasn't I that needed it. But interesting to know that it actually is possible
<FromGitter> <radarek> <akwiatkowski> Yes, it's extreme case but because it's doable in Crystal it worries me a bit.
<akwiatkowski> I was looking for `previous_def` thanks, hovewer I think split custom code to other methos would be cleaner.
bjz has quit [Ping timeout: 252 seconds]
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
bjz has joined #crystal-lang
<FromGitter> <asterite> Monkey-patching is extremely useful for fixing buggy code until it is merged remotely. For example you find a bug in the std, you can fix it and not wait until the next release. Same holds for any shard. I find this to be the best case for this. Plus, if you redefine a method incorrectly chances are you will either get a compile error (crystal is typed), or if it's a core method like Array#size or Int#+ then it will crash
<FromGitter> ... immediately, so those monkey-patches are technically impossible to do
soveran has quit [Ping timeout: 256 seconds]
A124 has quit [Read error: No route to host]
<RX14> @spalladino i'm sure if we split the issues up into segments we can work to re-tag everything together
A124 has joined #crystal-lang
<RX14> I think monkey patching is quite useful, I've used it to patch in things to the standard library while waiting for the next release.
Arney has joined #crystal-lang
<Arney> howdy!
<crystal-gh> [crystal] asterite pushed 2 new commits to master: https://github.com/crystal-lang/crystal/compare/39ffa702cbd7...94fc8ab6ac0b
<crystal-gh> crystal/master 94fc8ab Ary Borenszweig: Formatter: fixed missing space before asm modifiers. Fixes #3756
<crystal-gh> crystal/master 7fc782b Ary Borenszweig: Parser: fixed incorrect parsing regarding the ternary operator. Fixes #3639
<RX14> Overriding Array#size only segfaults because Array uses Pointer, which is unsafe
<RX14> it's the same as any unsafe code
<Arney> How is threading going in crystal? Can i crosscompile to arm?
<RX14> Arney, currently the concurrency model is good, but only runs in a single thread
<RX14> and yes, we can target ARM
<Arney> can i also target arm from x86?
<RX14> but it's not all too well tested
<RX14> you get an object file which you copy to ARM then link from arm
<Arney> :o that's odd
<Arney> but i will test
<RX14> or you can set up a complete arm linker in x86 if you want
<RX14> but thats harder
<RX14> and more error prone
<Arney> so crystal itself can produce arm machinecode, but is unable to link?
<crystal-gh> [crystal] asterite pushed 3 new commits to master: https://github.com/crystal-lang/crystal/compare/94fc8ab6ac0b...d1159e5c1c68
<crystal-gh> crystal/master d1159e5 Julien Portalier: sockets: add SO_REUSEPORT option
<crystal-gh> crystal/master afb5c53 Julien Portalier: Sockets refactor: avoid extra allocations
<crystal-gh> crystal/master 56dec21 Julien Portalier: Sockets refactor: allow any family/type/protocol association...
<Arney> guess that makes sense
<RX14> yes because you need an ARM environment on x86 to link
<RX14> yes because you need an ARM environment on x86 to link for ARM
<RX14> so it's just easier to link on ARM
<Arney> yeah great, i will play around with it a bit
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://github.com/crystal-lang/crystal/commit/0dfd4690b178f58675ba96fe1e55432491a368d8
<crystal-gh> crystal/master 0dfd469 Ary Borenszweig: Run formatter
<Arney> what's the problem with having a single thread when it comes to threading?
<RX14> the problem?
<Arney> why can't crystal spread to multiple cores
<RX14> multiple things right now
<RX14> the GC needs a tiny patch, and a lot of the stdlib needs reworking
<RX14> the scheduler is only built to work on a single core
<RX14> and we don't really have any concurrent collections or the like
<Arney> okay thank you for the answers
<RX14> it'll be done within 6 months I would guess
<Arney> super hyped for that
<RX14> Arney, read this issue for how to cross-compile for ARM https://github.com/crystal-lang/crystal/pull/3424
<RX14> you basically want to add --cross-compile --target arm-unknown-linux-gnueabihf to your crystal compile command
<RX14> then you'll copy the object file and run the outputted lniker command
<Arney> im actually not an export when it comes to the millions of different ARM subtypes
<Arney> will it be something that runs on every arm?
<RX14> however you need to clone the crystal source code on ARM and run `make deps` and modify the lniker command a bit too
<RX14> it's not hard just not simple
<RX14> Arney, well
<RX14> i don't know
<Arney> :D
<RX14> its a bit hit and miss I think
<RX14> there's no CI on arm
<RX14> which I am trying to fix
<Arney> are you Julien Portalier?
<RX14> nope
<FromGitter> <sdogruyol> lol :D
<Arney> RX14: what is "CI"?
<RX14> continuous integration
<Arney> oh geez now i need to google
<RX14> basically running the specs on an ARM device for every commit
<RX14> currently we only run the compiler/stdlib tests on x86
<RX14> for linux and osx
<RX14> so anything which is not that we never know if or when it breaks
<Arney> i get it
<Arney> how do you people have time for this during your normal job?
<Arney> i wished i could help with such a cool project, but i know several i would like to support
<RX14> well first I don't have a job
<Arney> good for you? i guess :D
<RX14> asterite and the people at manas can work on crystal par-time at their job I think
<Arney> geez lucky ones
<RX14> Arney, i guess full-time education is a job
<RX14> in a way
<Arney> educating yourself?
<RX14> college
<Arney> ah okay, still wondering how people manage to work on oss projects
<Arney> if i got welfare or something, that would be all i do
<RX14> after work and on the weekends too
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 250 seconds]
<travis-ci> crystal-lang/crystal#0dfd469 (master - Run formatter): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/186332519
gcds has joined #crystal-lang
gcds has quit [Client Quit]
Kug3lis has joined #crystal-lang
Kug3lis is now known as Kug3lis_off
<FromGitter> <tekjar> Programming langs like nim and rust are making it compulsory to cover all cases during expression matching
<FromGitter> <tekjar> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=585d2a2e0730ce6937004133]
<FromGitter> <tekjar> Any reason why crystal is bit lineant about this?
<FromGitter> <asterite> What if you don't want to cover all cases?
<crystal-gh> [crystal] MakeNowJust opened pull request #3757: Iterator::Flatten#rewind returns iterator itself (master...fix/iterator/flatten-rewind) https://git.io/vMeM6
<dom96> In Nim's case you would just explicitly tell it that you don't want to cover all cases by adding "else: nil"
<RX14> discovering "all cases" is probably quite hard
mgarciaisaia has joined #crystal-lang
soveran has joined #crystal-lang
<crystal-gh> [crystal] asterite closed pull request #3757: Iterator::Flatten#rewind returns iterator itself (master...fix/iterator/flatten-rewind) https://git.io/vMeM6
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vMeDF
<crystal-gh> crystal/master 352d5f0 TSUYUSATO Kitsune: Iterator::Flatten#rewind returns iterator itself
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vMeDx
<crystal-gh> crystal/master 991e39b Ary Borenszweig: Compiler: require free vars to be specified with `forall`
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
soveran has quit [Ping timeout: 256 seconds]
<FromGitter> <asterite> There's this, but it's quite ugly: https://play.crystal-lang.org/#/r/1hlg
<FromGitter> <asterite> But yeah, the general case is quite hard. In most cases not covering all case will make Nil somehow get into the type of the returned value and you'll get a compile error... and if not, it probably means your code is handling nil well
<FromGitter> <asterite> but it's something that could be improved
matp has quit [Quit: Bye!]
Philpax has quit [Ping timeout: 248 seconds]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://github.com/crystal-lang/crystal/commit/4f71e6ebff111b3c17dba90d63a9ac571df973ba
<crystal-gh> crystal/master 4f71e6e Ary Borenszweig: Fixed sample for next version
Kug3lis_off has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vMeSx
<crystal-gh> crystal/master 663c75d Ary Borenszweig: Don't include `libs` in CRYSTAL_PATH anymore
Kug3lis has joined #crystal-lang
matp has joined #crystal-lang
<FromGitter> <tekjar> I just happen to like the idea that ignoring a case should be explicit. :)
<travis-ci> crystal-lang/crystal#663c75d (master - Don't include `libs` in CRYSTAL_PATH anymore): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/186357430
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vMeQT
<crystal-gh> crystal/master f15f5a8 Ary Borenszweig: Updated Changelog
<Kug3lis> Anyone knows how to verify RSA signature using public key in pkcs#1 format using crystal?
Kug3lis is now known as Kug3lis_off
Kug3lis_off is now known as Kug3lis
soveran has joined #crystal-lang
ponga has joined #crystal-lang
soveran has quit [Ping timeout: 250 seconds]
<travis-ci> crystal-lang/crystal#f15f5a8 (master - Updated Changelog): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/186363712
Kug3lis is now known as Kug3lis_off
Kug3lis_off has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
akwiatkowski has quit [Ping timeout: 264 seconds]
Kug3lis has joined #crystal-lang
Kug3lis has quit [Ping timeout: 250 seconds]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vMehz
<crystal-gh> crystal/master 62bb206 Ary Borenszweig: Fixed stalled compilation when using LLVM 3.5
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 256 seconds]
<travis-ci> crystal-lang/crystal#62bb206 (master - Fixed stalled compilation when using LLVM 3.5): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/186391622
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vMveh
<crystal-gh> crystal/master b1416e2 Ary Borenszweig: Updated Changelog
Ven has joined #crystal-lang
<travis-ci> crystal-lang/crystal#b1416e2 (master - Updated Changelog): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/186396417
A124 has quit [Quit: '']
<yopp> uh. I'm having hard time getting static binary on linux
soveran has joined #crystal-lang
<yopp> It complains that it can't find mongoc-1.0, but `ld -lmongoc-1.0` only shows me the warning about missing`entry symbol _start`
A124 has joined #crystal-lang
<FromGitter> <johnjansen> seasons greetings all . can anyone tell me what is wrong with the following … im having a festivity induced brain freeze ⏎ ⏎ ```d = nil.as(Time | Nil) ⏎ e = d.not_nil!.to_utc.to_s("%Y-%m-%dT%H:%M:%SZ")``` [https://gitter.im/crystal-lang/crystal?at=585d6f11c5a4e0233bc1be56]
soveran has quit [Ping timeout: 256 seconds]
<FromGitter> <johnjansen> the `not_nil!` is causing ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=585d6f35058ca96737843b3e]
<FromGitter> <asterite> Well, d is nil... what did you expect?
<FromGitter> <johnjansen> hi Ary — haha … so the real line setting `d` is `d = Time.parse(date_string, "%F") rescue nil`
<FromGitter> <asterite> So maybe the parsing fails and you are getting nil? What are the contents of date_string?
<FromGitter> <johnjansen> where date_string is what you would expect, except when its something else … like this `2022-01-dfdsf01`
<FromGitter> <johnjansen> so it can fail yes
<FromGitter> <johnjansen> thats the idea behind the rescue and the subsequent not_nil!
<FromGitter> <radarek> not_nill! raise exception when d is set to `nil`
<FromGitter> <johnjansen> thanks @radarek … im an idiot some days
<FromGitter> <asterite> you probably want `d.try &.to_utc.to_s(...)`, or maybe `if d; ...; else; ...; end` or something like that
<FromGitter> <asterite> (note that in the try version the result can still be nil)
<FromGitter> <johnjansen> thats exactly what i want, thanks Ary … and merry christmas
<FromGitter> <asterite> to you too :-)
matp_ has joined #crystal-lang
matp has quit [Ping timeout: 260 seconds]
akwiatkowski has joined #crystal-lang
<crystal-gh> [crystal] Sija opened pull request #3759: Docs cleanup (master...docs-cleanup) https://git.io/vMvIS
greengriminal has joined #crystal-lang
<crystal-gh> [crystal] Sija opened pull request #3760: Remove outdated TODOS (master...remove-todos) https://git.io/vMvm5
Arney has quit [Quit: Lost terminal]
ponga has quit [Quit: Connection closed for inactivity]
pawnbox has quit [Remote host closed the connection]
bjz has joined #crystal-lang
soveran has joined #crystal-lang
<splitty_> Do Crystal `fun`s adhere to cdecl?
soveran has quit [Ping timeout: 256 seconds]
<BlaXpirit> splitty_, well yeah if understand correctly, that's their whole point
<splitty_> Okay, thanks. I was having issues with a struct passed on the stack and was wondering whether I should mark the function Naked and handle that stuff myself
<RX14> you can always manually declare the calling convention
<RX14> if it's inter-crystal code then any calling should work flawlessly
<RX14> otherwise it's a bug
<RX14> actually crystal always uses cdecl by default I think
binBASH has joined #crystal-lang
<RX14> from what I read Cdecl is what the GNU abis use throughout
<RX14> but i'm not knowledgable about such things
<RX14> splitty_, ^
<splitty_> Yeah, should be cdecl
<splitty_> This is really strange :D
<RX14> i don't think def vs fun changes the CC
<RX14> just the mangling
<RX14> and symbol export
<RX14> not that that matters to you
<splitty_> RX14, apparently the size of my kernel is 40 bytes, according to the multiboot info structure.
pawnbox has joined #crystal-lang
<splitty_> That's just impossible and I can't figure out what's happening
<RX14> no idea
<RX14> show me the code and i'll have a look
<Yxhuvud> 40 bytes seems small enough that it should be possible to look at the output
<splitty_> This is strange.. Maybe that value is in kb, that would make more sense
<RX14> hmm
<splitty_> The kernel is 36kb and the multiboot info struct reports a value of 40
<RX14> any docs?
<splitty_> Just the official multiboot docs on gnu.org, but they are.. really badly documented
<RX14> hah
<splitty_> "These indicate where the section header table from an ELF kernel is, the size of each entry, number of entries, and the string table used as the index of names."
<splitty_> The size of each entry. How helpful.
<RX14> well i would assume in bytes
<RX14> if it's each entry
<RX14> i could imagine 40 bytes for one of the ELF sections
<splitty_> Yeah, but then it makes no sense that the value is 40
<RX14> but
<RX14> it says 40 bytes for a ELF section
<RX14> not which ELF section
<splitty_> hmm..
<splitty_> All I need is an address at the end of the kernel, so I can place my heap there.
<RX14> well actually
<splitty_> Currently I'm doing elf_addr + elf_size
<RX14> ELF entry size
<RX14> would probably be the size of the ELF entry
<RX14> i.e. the metadata
<RX14> because it's size + number
<RX14> which implies they're all the same size
<RX14> i.e metadata
<RX14> "section header table" which would contain "elf entries" which are all metadata, and it gives you the size of each one + how many there are
<RX14> maybe
<RX14> i'm guessing here
<splitty_> "They correspond to the ‘shdr_*’ entries (‘shdr_num’, etc.) in the Executable and Linkable Format (elf) specification in the program header. All sections are loaded, and the physical address fields of the elf section header then refer to where the sections are in memory".
<splitty_> Just found this.
<RX14> so it's metadata?
<splitty_> I have no idea what "the shdr_* entries" are
<RX14> read the ELF spec?
<splitty_> Yeah I'm doing that right now
<RX14> well how big is the address space you're working with? if it's massive can't you just take the start address and add 10 magabytes?
pilne has joined #crystal-lang
<splitty_> RX14, not sure..
<splitty_> There has to be a better way.
<splitty_> RX14, would I be able to access a linker symbol from Crystal?
<RX14> if you were 64bit you could just reserve 1TiB for the kernel code and have done with it!
<splitty_> Right.. ^^
<splitty_> Well I want this to be portable so I can't really just get long-mode going and hope that it fixes everything
<RX14> yeah
<RX14> well i would venture to stack overflow then I guess
<splitty_> RX14, in the linker script I could easily define a linker symbol for the end of the kernel
<RX14> or mailinglists or sth
<splitty_> And I doubt there's a guide on how to use linker symbols in Crystal on SO :P
<RX14> uhh
<RX14> i don't even know what linker symbols are
<RX14> how would you use them in C?
<splitty_> RX14, they're basically pointers defined in the linker
<RX14> would it be like an external veriable?
<splitty_> Yep, just an external variable. No idea how that works in Crystal tyhough
<splitty_> though*
<RX14> ok
<RX14> you want to define a lib section
<RX14> and use $foo to declare an external variable named foo
<RX14> like this
<RX14> it's easier to link the docs
<RX14> it has an errno example there which should be illustrative
<splitty_> Thanks, I think I got it working :D
<RX14> the linker thingy?
<splitty_> Yeah, well at least it compiles
<splitty_> Now, I'm having a bit of a problem here
<splitty_> A linker symbol has no actual value, it's just an address.
<splitty_> So in C I'd do &end_of_kernel to get the actual value
<splitty_> pointerof(LibBootstrap.end_of_kernel).address doesn't work though
<RX14> so
<RX14> it's a pointer
<RX14> isn't it
<RX14> so seclare it as one?
<RX14> i assume it's 32bits wide
<RX14> if not you might have to declare it the right width and use Pointer.new(address)
<RX14> well Pointer(UInt8).new(address)
<splitty_> I did, but if I make it a Pointer(UInt32), the address of the pointer is the same as if I'd make it a UInt32 directly
<splitty_> That doesn't seem right. But maybe it is and I'm just completely wrong
<RX14> yes but you don't want the address of it
<RX14> you want its value
<RX14> the address of the variable is constant
<splitty_> Well, the value is 0
<RX14> then it's not working
<RX14> can you show me the code?
<splitty_> It's just end_of_kernel = .; in the linker file and $end_of_kernel : Pointer(UInt32) in the kernel
<splitty_> I think what I want is the address, not the value
<RX14> oh yes it would be pointerof(foo) in that case
<splitty_> and foo would be UInt32? Or a Pointer itself?
<splitty_> Okay, I think I got a usable value
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<RX14> it wouldn't matter would it?
<RX14> it could be any type and only the address of it would matter
<splitty_> Yeah I guess that's right
<splitty_> Thank you for your help
<RX14> no problem
<binBASH> Question regarding C bindings. Is it only possible to have them for libs or can you call C code somehow as well? I'm especially looking for using the netmap framework from within Crystal
<RX14> what do you mean?
<splitty_> You can only define C structs within libs, if that's what you mean
<RX14> binBASH, i'm not sure what you mean by "libs" vs "C code"
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
greengriminal has quit [Ping timeout: 265 seconds]
greengriminal has joined #crystal-lang
<binBASH> RX14: I want to call C code not inside a lib
<binBASH> Using some headers
<binBASH> these headers
<RX14> you just compile your C code into a library then
<RX14> and then bind it from crystal
greengriminal has quit [Ping timeout: 246 seconds]
greengriminal has joined #crystal-lang
<binBASH> Ok, so more complicated than via golang
<RX14> well how would you do it in go?
<RX14> does it compile C for you?
<RX14> seems like a bad idea to me
<binBASH> for example
<RX14> thats just silly
<splitty_> +1
<RX14> including C in comments seems like a hack to me
mgarciaisaia has left #crystal-lang [#crystal-lang]
<RX14> if netmap is a library, then the header file describes how you can bind it using `lib`
<RX14> if it's a single-header library then you can build the header and link with that
<splitty_> hmm..
<splitty_> RX14, this kernel stuff is just crazy
<splitty_> This works fine
<RX14> yes?
<splitty_> But this crashes qemu: https://puu.sh/sZ84t/fd0544cdbb.png
<binBASH> that's the rust implementation
<splitty_> And with crashes I mean.. completely destroys
<splitty_> It causes a core dump and I have to restart bash. :D
<RX14> binBASH, yes, and it binds it just like you would with crystal
<splitty_> Now.. if I remove that first puts, it works
<binBASH> RX14: So there is hope for me :-)
<splitty_> Doesn't have anything to do with the heap, just with the symbol and the pointer, apparently
vivus-ignis has quit [Ping timeout: 256 seconds]
<RX14> splitty_, well is the pointer value sane?
<splitty_> yes
<splitty_> It actually looks like to_i32 causes the crash
<RX14> also why do you pass the pointer as a u32 instead of a pointer?
<splitty_> Just resolving the pointer doesn't kill qemu
<RX14> interesting
<RX14> very interesting
soveran has joined #crystal-lang
<splitty_> RX14, it's the start address of the heap, and I store that as a UInt32 (aliased as USize)
<RX14> why not sure it as a Void*?
<RX14> store*
<RX14> it shouldn't matter
<RX14> it's a sidetrack
<splitty_> RX14, I meant to_u32, not to_i32
<splitty_> Yeah just changed that
<RX14> no idea what could be causing that
<RX14> how can casting an int32 to an int32 crash?
<splitty_> If I store it as a Void it doesn't crash, but it looks like the pointer address becomes zero then o_O
<RX14> what?
<splitty_> RX14, it's an UInt64 (the pointer address)
<RX14> ih
<RX14> oh*
<RX14> well
<RX14> wait
<RX14> so do the pointerof() and then print the pointer.address and that works?
<splitty_> Oh dear
<splitty_> Error: you've found a bug in the Crystal compiler.
<RX14> oh wow
<splitty_> Not again :D
<RX14> this doesn't seem to be going well
<splitty_> Module validation failed: Stored value type does not match pointer operand type!
<splitty_> store %Nil zeroinitializer, i8** %end_of_kernel
<splitty_> i8*
<RX14> try not declaring end_of_kernel as Void
<RX14> declare it as UInt8
<splitty_> That compiles
<splitty_> But it crashes QEMU
<RX14> and then take a pointer and just print the address
<RX14> nothing else
<RX14> no Heap.init
pawnbox has quit [Remote host closed the connection]
<splitty_> That works, too
<RX14> then it must be the heap that's crashing
<splitty_> Well let's try something else
<RX14> you sure the memory is writable?
<RX14> at the end_of_kernel
<splitty_> I don't have a GDT yet, everything should be writeable
<RX14> hmm
<RX14> interesting
<splitty_> OH
<RX14> oh?
<splitty_> Heap.init doesn't cause the crash
<RX14> hmm
<splitty_> It's actually run_self_tests
<RX14> ohh
<RX14> well
<RX14> the tests failed then I guess
<RX14> kek
<splitty_> What I really don't understand though
<splitty_> Is that everything works if I remove the first puts
<splitty_> I can add 100 puts in the kmain function, but one puts at the beginning of kearly crashes QEMU
<RX14> but only with the run_self_tests too?
<RX14> thats so weird
<splitty_> It doesn't make any sense
<RX14> maybe try deciphering what qemu spits out
<splitty_> Well it's just a core dump with all the registers and stuff
<RX14> try debugging the assembly
<RX14> like dump the assembly
<RX14> and work out whats going on with that coredump
<splitty_> yeah
<RX14> oh wait, that's qemu's coredump
<RX14> or the vms
<splitty_> It's qemu's coredump
<RX14> oh dear
bjz has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
soveran has quit [Remote host closed the connection]