ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.33.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
gangstacat has quit [Ping timeout: 246 seconds]
ur5us has quit [Ping timeout: 240 seconds]
ur5us has joined #crystal-lang
gangstacat has joined #crystal-lang
return0e has joined #crystal-lang
return0e_ has quit [Ping timeout: 264 seconds]
Stephie has quit [Read error: Connection reset by peer]
Stephanie has joined #crystal-lang
renich has quit [Quit: renich]
ur5us has quit [Ping timeout: 256 seconds]
ur5us has joined #crystal-lang
Vexatos has quit [Quit: ZNC Quit]
<FromGitter> <Afront> Is it okay to use the unsafe method `#to_slice` in this way? ⏎ ⏎ ``` some_string.bytes.each { |byte| STDOUT.write_byte byte }``` [https://gitter.im/crystal-lang/crystal?at=5e7c283fbf65703264dc13e4]
<FromGitter> <Blacksmoke16> why not just do `puts some_string`?
<FromGitter> <Afront> I was also wondering about that as well ⏎ Since I'm not sure on what the differences are between `print` and `write` aside from converting the object to a string
<FromGitter> <Afront> I was also porting C code, which does something similar to the first code snippet
<FromGitter> <Blacksmoke16> mainly what they accept
<FromGitter> <Blacksmoke16> print just does `obj.to_s self` writing the obj's string representation to the IO
Vexatos has joined #crystal-lang
<FromGitter> <Blacksmoke16> while write requires an array of bytes
<FromGitter> <Afront> oh okay, I guess I'll just use print then ⏎ Thanks!
ur5us has quit [Ping timeout: 256 seconds]
gangstacat has quit [Ping timeout: 272 seconds]
gangstacat has joined #crystal-lang
postmodern has quit [Read error: Connection reset by peer]
postmodern has joined #crystal-lang
<FromGitter> <elorest> Should folders and filenames in crystal code bases use hypens or underscores? It seems much more mixed than ruby or python.
_ht has joined #crystal-lang
_whitelogger has joined #crystal-lang
asterite has joined #crystal-lang
<FromGitter> <confact> @asterite added the feature request at https://github.com/crystal-lang/crystal/issues/8946
HumanGeek has joined #crystal-lang
Human_G33k has quit [Ping timeout: 250 seconds]
<FromGitter> <j8r> `print ""` is equivalent to `STDOUT.write_utf8 "".to_slice`
postmodern has quit [Quit: Leaving]
<FromGitter> <asterite> @elorest I always use underscores
Liothen has joined #crystal-lang
<FromGitter> <stronny> does it matter?
<FromGitter> <stronny> I guess it would if Crystal could autorequire files based on first discovered module/class
<FromGitter> <stronny> but that's a whole lot of complexity for marginal profit, so I wouldn't prioritize it
<FromGitter> <stronny> and even then -/_ distinction could be accounted for anyway
* FromGitter * Blacksmoke16 wants ES6 imports
<FromGitter> <stronny> I had a though once about anonymous code that gets named upon require. Something like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e7ca48ae4eb057b38709b18]
<FromGitter> <Blacksmoke16> just having a way to import a single type from a namespace would be 💯
<FromGitter> <Blacksmoke16> versus having to include all that namespace's types, or use an alias
<FromGitter> <stronny> alias?
<FromGitter> <Blacksmoke16> less than ideal
<FromGitter> <Blacksmoke16> just to make the type names shortert
<FromGitter> <stronny> that's a complex conversation, many conflicting goals here
<FromGitter> <Blacksmoke16> im sure its not trivial either
<FromGitter> <confact> A thing I have on `as` on require/import in ES6 is that sometimes they are named totally different on every place it is imported and I have to go check what is actually required/imported. The code gets messy fast, especially if many people have different ideas on naming.
<FromGitter> <Blacksmoke16> well `as` would be an alias you define
<FromGitter> <Blacksmoke16> which is easily solved by having some standards on naming
<FromGitter> <Blacksmoke16> at least this way you would be able to tell by looking at the top of the page
ua has quit [Ping timeout: 246 seconds]
travis-ci has joined #crystal-lang
travis-ci has left #crystal-lang [#crystal-lang]
<travis-ci> crystal-lang/crystal#9dbd914 (master - Fix typo on "iterate" (#8941)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/667266875
ua has joined #crystal-lang
MasterdonX has joined #crystal-lang
masterdonx2 has quit [Ping timeout: 264 seconds]
travis-ci has joined #crystal-lang
<travis-ci> crystal-lang/crystal#c8c6685 (master - Windows: Remove the workaround using vsnprintf. (#8942)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/667268237
travis-ci has left #crystal-lang [#crystal-lang]
<DeBot> https://github.com/crystal-lang/crystal/pull/8942 (Windows: Remove the workaround using vsnprintf.)
<FromGitter> <j8r> this bots are pointless...
<FromGitter> <j8r> There are already GitHub notifications, plus Gitter activity
<FromGitter> <sam0x17> is there an automatically sorted container in the standard library (like a binary tree)?
<FromGitter> <stronny> what's the usecase?
<FromGitter> <sam0x17> bunch of fibers are building up an array of items that gets sorted by an attribute at the end -- right now just doing `results.sort_by { |item| item["id"] }`
<FromGitter> <stronny> how is the array getting used?
<FromGitter> <stronny> sort once is cheaper than rebalancing tree on every insert I think
<FromGitter> <sam0x17> yeah you're probably right
<FromGitter> <sam0x17> I was just thinking that
<FromGitter> <stronny> answering your question I can't think of any
<FromGitter> <stronny> shards probably
<FromGitter> <sam0x17> yeah I know of some shards that have it I just wanted to make sure I'm not missing out on some standard library container I don't know about
<FromGitter> <stronny> also array is O(1) on access, trees are typically O(log N)
<FromGitter> <sam0x17> yeah java has a hybrid with O(1) iteration and O(log N) insert
<FromGitter> <sam0x17> I forget what it's called but that's what I was thinking of
<FromGitter> <sam0x17> probably just a red black tree
<FromGitter> <sam0x17> or AVL
<FromGitter> <stronny> you can do that with additional memory sure
<FromGitter> <sam0x17> yeah, array is better for this :)
<xyhuvud> That particular usecase might be better served by a heap. Not that we have that either in stdlib. personally I'd really love to see a good heap and a good (b-)tree implementation in stdlib.
<xyhuvud> time has run away from red black and avl trees - they are not very good from a cache perspective.
<xyhuvud> or well, heaps don't allow iteration, but it depends on what you'd actually use the contents for.
DTZUZU2 has quit [Ping timeout: 250 seconds]
DTZUZU2 has joined #crystal-lang
HumanGeek has quit [Read error: Connection reset by peer]
HumanGeek has joined #crystal-lang
postmodern has joined #crystal-lang
<oprypin> but with `@llvm_mod` being a different object at that point, causing a failure `Undefined llvm function: __CxxFrameHandler3`. this happens only if i run this code *on* Windows, but works correctly (@llvm_mod always matches) if I cross-compile on Linux to Windows. see also `@mod.to_unsafe` on the screenshot. do you know what it could be?
<Stephanie> oh god
<oprypin> :D
<Stephanie> oh, right
<Stephanie> right tight
<Stephanie> --single-module
<Stephanie> on windows
<Stephanie> will fix it, as a workaround
<oprypin> oh well thats easy :o
<Stephanie> the answer is, that i fucked up
<Stephanie> i only add the personality function definition in the main module
<oprypin> yea apparently.
<Stephanie> which always worked fine since i was cross-compiling
<Stephanie> and that implies single-module
<Stephanie> i need to add a fix which just checks if it's defined for each module
<Stephanie> and defines it if it's not
<Stephanie> like all the other functions
<Stephanie> i just forgot about that
<oprypin> Stephanie, thank you, that workaround helps
<Stephanie> nice
<Stephanie> it's what i thought then
<Stephanie> i guess i'll PR a fix?
<oprypin> Stephanie, sure, would be nice.
<oprypin> Stephanie, how far did u get with running Crystal itself? i assume since you added info about installing LLVM on the wiki page, you at least tried it?
<Stephanie> yeah
<Stephanie> it worked, with a patch
<Stephanie> which still lives in the windows branch of my fork
<Stephanie> but it like
<Stephanie> compiled hello world
<Stephanie> on windows
<oprypin> nice. so im just duplicating that work :D
<Stephanie> "shitty WIP stubbing" sums it up really
<oprypin> down to the `BUILT_TARGETS = [:x86]` line 😂
<Stephanie> hehe
<Stephanie> i do that every time i have to cross-compile
<oprypin> Stephanie, u could just build llvm on windows with aarch maybe?
<Stephanie> rebuild llvm: 1 hour
<Stephanie> hack crystal: 1 minute
<Stephanie> hmm
<oprypin> "every time" though
<Stephanie> i didnt mean just with windows
<Stephanie> i was porting to netbsd recently and they only had x86 by default too
<Stephanie> (ran into some cursed stuff with bdwgc causing stack overflows when collecting though so ???)
<FromGitter> <sam0x17> can I specify a bound on a generic class type specifier?
<FromGitter> <sam0x17> like I want to add a method to Array(T) but only if T is something specific
<FromGitter> <Blacksmoke16> i want to say no
<FromGitter> <Blacksmoke16> what would happen if you try to use it on something that doesnt support it? compile time error or?
<FromGitter> <Blacksmoke16> there isnt a built in way to do this but you could do something like
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e7cf73e04405b1a718f3975]
sagax has quit [Read error: Connection reset by peer]
<FromGitter> <kinxer> @manveru If you haven't found it yet, it turns out that there's a more complete GeoJSON shard than mine: https://github.com/geocrystal/geo_json ⏎ It makes me sad to be outdone, but it looks like a really excellent shard.
<FromGitter> <sam0x17> yeah I was thinking the method would be missing so compile time error
<FromGitter> <sam0x17> it's all good tho I'm going with a different structure was just curious
<FromGitter> <Blacksmoke16> that should work the same
<FromGitter> <sam0x17> is there a built-in way of getting the domain from a `URI`? or am I justified in writing a bit of string parsing
<FromGitter> <sam0x17> got it -- there's a `.host`
<FromGitter> <j8r> `URI#hostname`?
<FromGitter> <j8r> there is also `URI#host` yes
<FromGitter> <sam0x17> difference?
<FromGitter> <Blacksmoke16> looks like `hostname` is essentially the same as `host`, just handles unwrapping ipv6 hosts
<FromGitter> <sam0x17> gotcha
<FromGitter> <kinxer> Am I remembering correctly that recursive aliases are a "may not survive 1.0" feature of the language (like symbols)?
<FromGitter> <Blacksmoke16> recursive struct would be the better approach yes
<FromGitter> <kinxer> Can we use recursive structs now?
<FromGitter> <Blacksmoke16> thats what `JSON::Any` is yes
<FromGitter> <Blacksmoke16> where `JSON::Any` is a struct
<FromGitter> <kinxer> Hm... I thought I remembered at some point that we couldn't do that.
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <kinxer> https://carc.in/#/r/8rv6
<FromGitter> <kinxer> That's what I was thinking of.
<FromGitter> <asterite> You can't have recursive structs. But JSON::Any works because it's a union of all primitive types or reference types, so there's the pointer of the reference indirection which makes it be "recursivee"
<FromGitter> <asterite> It's like having a class with a member referring to itself
<FromGitter> <Blacksmoke16> ahh, you could use a class for that
<FromGitter> <asterite> "it's a union of all" -> well, it has an instance vars that's a union of all...
<FromGitter> <kinxer> https://carc.in/#/r/8rva
<FromGitter> <kinxer> So I just need something that's a pointer (e.g. a class wrapper).
<FromGitter> <kinxer> Probably not related to the recursive struct thing, but can anyone tell me what I've done wrong here? https://carc.in/#/r/8rvf
<FromGitter> <kinxer> I'm expecting a third node, but it doesn't seem to be assigned.
travis-ci has joined #crystal-lang
<travis-ci> crystal-lang/crystal#e1b4e8f (master - Compiler: Honor LIBRARY_PATH as default library path): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/667403542
travis-ci has left #crystal-lang [#crystal-lang]
travis-ci has joined #crystal-lang
<travis-ci> crystal-lang/crystal#ef5f10f (master - Revert "Compiler: Honor LIBRARY_PATH as default library path"): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/667404103
travis-ci has left #crystal-lang [#crystal-lang]
Xeago has quit [Read error: Connection reset by peer]
ur5us has joined #crystal-lang
<watzon> Ok STDOUT being buffered is fucking with me
<FromGitter> <Blacksmoke16> `STDOUT.sync = true`?
<watzon> I just got a project set up in a pet container and tried to run it and wasn't getting any output. As soon as set `STDOUT.buffer_size = 0` I get output
<watzon> I was scratching my head trying to figure out what was wrong
<watzon> sync works as well
<FromGitter> <manveru> @kinxer that's also super new...
sagax has joined #crystal-lang
<FromGitter> <manveru> i should really make a shard for https://openrouteservice.org/ using that now :)
<FromGitter> <kinxer> It could be a bit more well-documented, but it's structured simply, more complete to the GeoJSON spec than my library, and seemingly equivalent speed-wise to my library (both can deserialize a quarter-GB GeoJSON file in about 4 seconds).
<FromGitter> <kinxer> That sounds really useful.
<FromGitter> <manveru> i'm using an ad-hoc class for it atm, it doesn't really need a ton of the geojson features, and i don't have much time to spend on it
<FromGitter> <manveru> https://gist.github.com/manveru/a599affce0968aa64e908309e745e30f if you want to try it
<FromGitter> <kinxer> Alas, I don't have the bandwidth for that right now (and it wouldn't be useful to *me* right now), but I hope you have the opportunity to spend more time on it at some point.
<FromGitter> <kinxer> I think geo applications would work really well in Crystal; for instance, it seems like the primary open-source map servers right now are in Javascript, C++, and Python. Crystal could provide near-C++ speed with better developer friendliness (arguably more than all three other languages).
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <elorest> > @elorest I always use underscores ⏎ ⏎ Thanks @asterite. Me too but lately I've gotten some push back. My thought is that since hyphen actually has meaning in english, math, dates etc, it shouldn't be used as a replacement for spaces in filenames. This allows for meaningful uses of hyphens such as `your_app_production_03-19-2020.log`.
<FromGitter> <Blacksmoke16> i also use hyphen to denote namespaces
<FromGitter> <Blacksmoke16> like `require "athena-dependency_injection"`
<FromGitter> <Blacksmoke16> that represents `Athena::DependencyInjection`
<FromGitter> <Blacksmoke16> ofc only really do that for the main file that you would require for a shard
_ht has quit [Remote host closed the connection]
<FromGitter> <Blacksmoke16> is there a way to tell if two objects are comparable?
f1refly has quit [Quit: bye fags]
<FromGitter> <Blacksmoke16> im trying to implement a `GreaterThan` constraint, however im ofc running into like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e7d33738d18836da41969d5]
ur5us has quit [Remote host closed the connection]
ur5us has joined #crystal-lang
<FromGitter> <Blacksmoke16> i kinda want to avoid adding something to object
<oprypin> > im trying to implement a GreaterThan why tho
<FromGitter> <Blacksmoke16> ``
<FromGitter> <Blacksmoke16> ```@[Assert::GreaterThan(value: 0)] ⏎ property age : Int32``` [https://gitter.im/crystal-lang/crystal?at=5e7d3752b05dc465027f5f72]
<oprypin> 😞
f1refly has joined #crystal-lang
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/8rzo well theres one bug