ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <oprypin:matrix.org> definitely answers that too. spoiler: yes, you're exactly right
<FromGitter> <watzon:matrix.org> ```if foo = bar.baz ⏎ # do something with foo ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=603ed19822a5ce4a912c8ba3]
<FromGitter> <js:nil.im> Yeah, I should read that πŸ˜€. I suppose my Ruby is a lot more rusty than I thought
aquijoule__ has joined #crystal-lang
aquijoule_ has quit [Ping timeout: 264 seconds]
<FromGitter> <js:nil.im> Now you can laugh about my initial code: https://fossil.nil.im/asyncdns-cr/dir?ci=tip πŸ™‚
<FromGitter> <js:nil.im> feedback welcome πŸ™‚
<FromGitter> <watzon:matrix.org> Ahhh now I get some of the initial confusion on structure
<FromGitter> <rymiel:rymiel.space> I found it surprising how... *exciting* reading that reference book at https://crystal-lang.org/reference/syntax_and_semantics/ was for the first time. I had no exposure with Ruby at the time and while I know the Crystal syntax is heavily inspired from Ruby, i just found it incredibly refreshing to see all the things that were possible with sugar in Crystal. At this point I don't think i can ever go
<FromGitter> ... back to a different syntax.
<FromGitter> <rymiel:rymiel.space> a gitbook better than most novels
<FromGitter> <watzon:matrix.org> Hint: running `crystal init lib [project name]` will initialize the basic structure of a crystal library
<FromGitter> <watzon:matrix.org> Emilia (https://matrix.to/#/@rymiel:rymiel.space): agreed. The gitbook is very informative. Another great resource is https://forum.crystal-lang.org. I learn new things all the time just by browsing recent posts.
<FromGitter> <watzon:matrix.org> @js
<FromGitter> <js:nil.im> I intentionally didn't do that yet since I wanted to learn about one thing after another, rather than have lot of boilerplate πŸ˜€
<straight-shoota> > a gitbook better than most novels
<straight-shoota> wow
<straight-shoota> must be reading crappy novels, then xD
hendursa1 has quit [Quit: hendursa1]
hendursaga has joined #crystal-lang
<straight-shoota> but great that you find the read refreshing, @rymiel
<FromGitter> <js:nil.im> ok, got parsing of `/etc/hosts` and `/etc/resolv.conf` done now. And it's 2:30 am. Time to call it a day. And nobody has complained about anything but not using `crystal init`, so apparently not that terrible πŸ˜€
<FromGitter> <js:nil.im> and tomorrow I gotta figure out how to read the registry on Windows πŸ˜‰
<straight-shoota> it's still unclear if this is going to land in stdlib or a shard
<straight-shoota> but you should be fine with just shelling out
<FromGitter> <js:nil.im> I guess I could also port my Windows Registry abstraction
<FromGitter> <js:nil.im> anyway, registry is kinda very much to the core on Windows, where it's hard to get far without it
<FromGitter> <js:nil.im> so, maybe something for stdlib
<FromGitter> <js:nil.im> how far back does Windows support go? XP? NT4? 98SE?
<straight-shoota> well the argument against it is not limited usefulness but that stdlib should only include cross-platform features
<FromGitter> <js:nil.im> because then there might also be some fun to be had with W vs A functions
<straight-shoota> I have no idea how far back it would work
<straight-shoota> but it's intended for fairly recent win32 API
<straight-shoota> stdlib uses W function
<FromGitter> <js:nil.im> ah, I am crazy enough to go all the way back to 98SE πŸ˜€
<FromGitter> <js:nil.im> if people don't mind, I might actually backport πŸ˜‰
<straight-shoota> have fun with it :shrug:
<FromGitter> <js:nil.im> aaaanyway, really time to sleep. Night!
<straight-shoota> but 32-bit windows isn't supported at all
<straight-shoota> gn8
<FromGitter> <js:nil.im> oh. That might be more important to tackle first then
<straight-shoota> or well, most of the API probably works
<straight-shoota> swapcontext is only implemented for x86_64 windows
<FromGitter> <jrei:matrix.org> Supporting unsupported OSes? Mad!
<FromGitter> <jrei:matrix.org> Unsupported by the company which made it
<FromGitter> <jrei:matrix.org> May be fun to do, but this won't be very useful...
sz0_ has joined #crystal-lang
sz0 has quit [*.net *.split]
r0bby has quit [*.net *.split]
sz0_ is now known as sz0
r0bby has joined #crystal-lang
DeBot has quit [Ping timeout: 272 seconds]
jhass has quit [Ping timeout: 240 seconds]
straight-shoota has quit [Ping timeout: 272 seconds]
asterite has quit [Ping timeout: 276 seconds]
r0bby has quit [Ping timeout: 258 seconds]
r0bby has joined #crystal-lang
straight-shoota has joined #crystal-lang
jhass has joined #crystal-lang
asterite has joined #crystal-lang
deavmi has quit [Remote host closed the connection]
deavmi has joined #crystal-lang
HumanG33k has quit [Read error: Connection reset by peer]
HumanG33k has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
_whitelogger has joined #crystal-lang
_ht has joined #crystal-lang
teardown has quit [Remote host closed the connection]
teardown has joined #crystal-lang
alexherbo2 has joined #crystal-lang
johnny101 has joined #crystal-lang
hendursa1 has joined #crystal-lang
hendursaga has quit [Ping timeout: 268 seconds]
<frojnd> What would be the nicest way to add to an verse_arr = Array(String) another array of string arr["foo", "bar"] I was hoping verse_arr << arr.flatten would work but I guess it doesn't Woul like to avoid looping over arr of strings if there is already made function
Flipez has joined #crystal-lang
<frojnd> I mean I can always do it in 2 lines verses_arr << arr.first; verses_arr << arr.last
<frojnd> Nope that won't work
<frojnd> Agh it works perfectly
sz0 has joined #crystal-lang
<FromGitter> <Luj8n> Hi! Is multithreading possible in Crystal? Cause I just pretty much read the whole documentation (love it <3) and it was said, that it's not possible: https://crystal-lang.org/reference/guides/concurrency.html#concurrency-vs-parallelism . Although in the api, it's written that you a spawn can be on a different thread? https://crystal-lang.org/api/0.36.1/toplevel.html#spawn(*
<FromGitter> ... ,name:String?=nil,same_thread=false,&block)-class-method
<FromGitter> <Luj8n> Also, is this the place to ask these kind of questions?
<FromGitter> <js:nil.im> Luj8n (Luj8n): I’m new to the language myself and you got me curios. There’s a preview_mt compile time flag being checked in the code. Googling for that, I found this: https://crystal-lang.org/2019/09/06/parallelism-in-crystal.html
<FromGitter> <Luj8n> hm
<repo> hi! I ran into this issue: `Missing hash key: "id" (KeyError)`
<repo> happens if i compile using --debug
<repo> ah there's already an issue
<repo> hmm
<straight-shoota> got a small repro?
<frojnd> Do I have to select table first (sqlite3) I get no such tabale. First I open DB and then `db.exec "insert into contacts values (?, ?)", "John Doe", 30` but I get no such table I created table with sqlite3browser
<frojnd> Argh I had wrong db
alexherbo22 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 264 seconds]
alexherbo22 has quit [Client Quit]
alexherbo2 has joined #crystal-lang
<frojnd> Ok so I did my_array.to_s to save array as a text into sqlite3 Now my string looks like this when I query DB: `"[\"foo\", \"bar\"]"` how can I convert it back to an array in crystal?
<FromGitter> <Blacksmoke16> save it as JSON then parse it after reading it?
alexherbo26 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 260 seconds]
alexherbo26 has quit [Ping timeout: 260 seconds]
alexherbo2 has joined #crystal-lang
<FromGitter> <wyhaines> Yeah. If you are wanting to save an array into a SQLite varchar field, your best bet is to save it in a serializable format like JSON.
alexherbo2 has quit [Ping timeout: 245 seconds]
<frojnd> Ok,.. make json inside crystal and save thta json as varchar to sqlite3...
<frojnd> Did I understand that correctly?
<FromGitter> <Blacksmoke16> right
sagax has joined #crystal-lang
andremedeiros has quit [*.net *.split]
woodruffw has quit [Ping timeout: 264 seconds]
woodruffw has joined #crystal-lang
andremedeiros has joined #crystal-lang
aquijoule__ has quit [Ping timeout: 256 seconds]
<FromGitter> <alexherbo2> @Blacksmoke16 should the lock file be stored?
<FromGitter> <Blacksmoke16> is your project a lib or app?
<FromGitter> <alexherbo2> why should we store for apps and not for libs
<FromGitter> <alexherbo2> oq is both for example
<FromGitter> <alexherbo2> but I do not see it in your repo
<FromGitter> <Blacksmoke16> because libs are meant to be included in other projects, which should contain the lock file
<FromGitter> <alexherbo2> my project is currently an app, but I want to be a lib too
<FromGitter> <Blacksmoke16> how would it be both?
<FromGitter> <alexherbo2> I provide a binary and also offer libs to require it for escaping shell commands
<FromGitter> <alexherbo2> I would like https://github.com/alexherbo2/kakoune.cr to be usable as a lib too
<FromGitter> <Blacksmoke16> id say you dont need the lock file then
<FromGitter> <alexherbo2> does it help for packaging to have lock files?
<FromGitter> <alexherbo2> I have been ping for a package pr https://github.com/NixOS/nixpkgs/pull/115011
<FromGitter> <Blacksmoke16> not really? As i think you'd be distributing a binary. If someone wants to build from source they can just install and build
<straight-shoota> If you intend users to run `shards install` in your project to get reproducible dependencies, you should include a lockfile.
<FromGitter> <oprypin:matrix.org> if you have a binary, you must add shard lock.
<FromGitter> <Blacksmoke16> if ofc the binary actually has deps, which `shell-escape` doesnt
<FromGitter> <asterite> Wouldn't specs be considered a binary? It would be bad to come back to the project two months later and find that it doesn't compile anymore...
<straight-shoota> yeah, technically true
<straight-shoota> but for specs it's not that relevant IMO
<straight-shoota> ofc checking in a shard.lock is not disallowed for lib shards
richbridger has joined #crystal-lang
bazaar has joined #crystal-lang
<FromGitter> <oprypin:matrix.org> @asterite: i prefer installing always-latest and running schedule
_ht has quit [Remote host closed the connection]
<FromGitter> <oprypin:matrix.org> and if i'm a library, well, it would actually be *better* "to come back to the project two months later and find that it doesn't compile anymore", otherwise users of the library will find out first :)
ua_ has quit [*.net *.split]
fifr has quit [*.net *.split]
xybre has quit [*.net *.split]
Welog has quit [*.net *.split]
Vexatos has quit [*.net *.split]
markmarkmark has quit [*.net *.split]
olbat has quit [*.net *.split]
Welog has joined #crystal-lang
ua_ has joined #crystal-lang
fifr has joined #crystal-lang
Vexatos has joined #crystal-lang
olbat has joined #crystal-lang
markmarkmark has joined #crystal-lang
xybre has joined #crystal-lang
<FromGitter> <asterite> Hehe, good point
duane has quit [Ping timeout: 240 seconds]
<FromGitter> <js:nil.im> Does Shards only support Git?
<FromGitter> <Blacksmoke16> can also use a path, but yea `git` is the main way outside of local dev
<FromGitter> <js:nil.im> hmm, damn. I have all my stuff in Fossil instead of Git πŸ˜•
<FromGitter> <Blacksmoke16> TIL there are people that dont use git πŸ˜†
<FromGitter> <js:nil.im> I used to, until GitHub became shitty and I no longer trusted them with bugs, wiki, etc., so I was looking for something self-hosted where you can also clone the bugs etc. - and found Fossil and migrated to it
<FromGitter> <js:nil.im> there's a git export, though
<FromGitter> <js:nil.im> so it's not that big of a deal
<straight-shoota> there's actually a PR pending to add mercurial support
<straight-shoota> it's not that much to do. I suppose fossil shouldn't be difficult either.
<straight-shoota> But you're one very few people using that :P
<FromGitter> <js:nil.im> yep, there isn't many people using Fossil - I don't know why. I guess because it came much later than Git and Mercurial πŸ˜‰
<FromGitter> <Blacksmoke16> to be fair could have still used git. Also have likt gitlab and bitbucket :shrug:
<FromGitter> <js:nil.im> well, neither of those *clone* the bugs and wiki etc
<FromGitter> <js:nil.im> I kinda liked being able to clone everything
<FromGitter> <js:nil.im> I can commit, then comment and resolve a bug - all offline. And then push it when back online.
<FromGitter> <Blacksmoke16> ah fair enough
<FromGitter> <js:nil.im> and it's super easy to set up for self-hosting. It's a single binary that can do scgi πŸ™‚
<FromGitter> <js:nil.im> and getting the same web interface locally, I only need to run `fossil ui` and have all the same things πŸ˜‰
<FromGitter> <js:nil.im> qq: if I have def foo(x : Array(String)), why can't I do foo([])?
<FromGitter> <Blacksmoke16> the type of the array needs to be known
<FromGitter> <Blacksmoke16> `foo [] of String` or `foo Array(String).new`
<FromGitter> <js:nil.im> but it can get it from the def foo?
<FromGitter> <Blacksmoke16> iirc there was an issue about that?
<FromGitter> <js:nil.im> why does it not infer it?
<straight-shoota> the compiler could theoretically infer it from the signature
<straight-shoota> but it doesn't (yet)
<FromGitter> <js:nil.im> I mean, it gives a helping error message, but that does not explain why it does not infer πŸ˜€
<FromGitter> <js:nil.im> so just a matter of not implemented yet?
<straight-shoota> probably
<straight-shoota> autocasting is relatively new addition addition to the language
<straight-shoota> works with number literals and enums
<FromGitter> <Blacksmoke16> (most of the time)
<FromGitter> <js:nil.im> btw, is @@ just private instead of protected?
<FromGitter> <js:nil.im> just saw that in some code
<FromGitter> <Blacksmoke16> class var
<FromGitter> <js:nil.im> ahh :)
<FromGitter> <js:nil.im> thx
<FromGitter> <js:nil.im> it's hard to google for sigils :D