<crystal-gh>
[crystal] mohd-akram opened pull request #5970: Improve static compilation support (master...static-compile) https://git.io/vpqGh
<RX14>
not any more
<RX14>
it's 1am
<FromGitter>
<girng> lmao
<RX14>
b y e
<FromGitter>
<Sija> yeah, it’s night mode for sure
<FromGitter>
<j8r> @asterite thanks, my bad I need to put some other conditions
<FromGitter>
<Sija> @RX14 I was hoping you’d explain me what do u mean with your comment regarding benchmarking this seemingly insignificant change
<FromGitter>
<girng> i love CRYSTAL
<FromGitter>
<BrucePerens> @bew fixed, thanks!
<FromGitter>
<bew> @asterite I'm trying to understand why #5752 happens, but can't seems to find how private things works, do you remember sth about it?
<FromGitter>
<BrucePerens> @RX14 If I create a string from a literal, does the data memory start from the readonly text of the ELF, and if I modify the string do I then get copy-on-write? This is an implementation detail that language users would not see.
<FromGitter>
<bew> strings are immutable, so as soon as you do a string modification you get a new (allocated) string
<FromGitter>
<asterite> bew because aliases are expanded to whatever the aliased type is, eagerly, so the privateness is lost. Probably super hard to fix. I'd really like to remove private types from the language, they only make things complex
<FromGitter>
<girng> i give up, i don't UNDERSTAND why it's not working
<FromGitter>
<girng> `Returns a String where all occurrences of the given string are replaced with the block's value.`
<FromGitter>
<ezrast> What is the block's value if counter <= 10?
<FromGitter>
<girng> im using an if statement, if counter is greater than 10, return "" (which is the returned for the block)
<FromGitter>
<girng> which is a BLANK string...
<FromGitter>
<girng> which is the blocks value a BLANK string
<FromGitter>
<girng> return value*
<FromGitter>
<ezrast> what result are you expecting?
<FromGitter>
<girng> only to replace the `\n` atfter the counter is greater than 10
<FromGitter>
<ezrast> so the block works properly when the counter is greater than 10, yes? It's the other case that's the problem.
<FromGitter>
<girng> yes, if greater than 10, return "" that replaces the rest of the \n's
<FromGitter>
<girng> `the given string are replaced with *the block's value*.`
<FromGitter>
<ezrast> I'm not asking about when it's greater than 10
<FromGitter>
<ezrast> do you know what value an if statement with a falsey condition evaluates to?
<FromGitter>
<girng> it evalutes tof alse, which shouldn't return anything
<FromGitter>
<girng> so iuno why its replacing all the \n's
<FromGitter>
<girng> if it's not returning anything, `block` doesn't have a value to replace anything
<FromGitter>
<ezrast> wrong on both counts
<FromGitter>
<girng> ok
<FromGitter>
<girng> well, that's what i got out of it from reading the description
<FromGitter>
<girng> it quite literally says that so
<FromGitter>
<girng> where all occurrences of the given *string are replaced with the block's value*.
<FromGitter>
<ezrast> an if statement that doesn't execute evaluates to nil: https://carc.in/#/r/3wnl
<FromGitter>
<ezrast> and nil is a value that can be returned
<FromGitter>
<girng> ok that makes that sense
<FromGitter>
<girng> however, why is nil replacing my string?
<FromGitter>
<ezrast> every single \n gets replaced by the return value of your block. Knowing what you now know, what values is it possible for your block to return?
<FromGitter>
<girng> so, all of them are replaced with a nil value, until greater than 10, of which are replaced by ""?
<FromGitter>
<ezrast> yep
<FromGitter>
<girng> but when i do puts or p
<FromGitter>
<girng> it doesn't show NIL
That_Guy_Anon1 has joined #crystal-lang
<FromGitter>
<girng> im so confused...
<FromGitter>
<girng> but your EXAMPLE, it shows NIL
<FromGitter>
<girng> ..............
<FromGitter>
<ezrast> gsub runs `.to_s` on the thing to make it a string
That_Guy_Anon1 has quit [Remote host closed the connection]
<FromGitter>
<girng> so when it gets converted to a string the `nil` isr eplaced, even when using `p`
<FromGitter>
<girng> and @oprypin said `p` is a debugging tool
<FromGitter>
<girng> why remove the nil's then
<FromGitter>
<girng> not fair at ALL
<FromGitter>
<ezrast> p isn't removing the nils
<FromGitter>
<ezrast> gsub is converting them to their string representation
<FromGitter>
<ezrast> it has to
That_Guy_Anon1 has joined #crystal-lang
<FromGitter>
<ezrast> because gsub returns a string
<FromGitter>
<girng> but p is a debugging tool, i should see them just like how the new lines get converted to \n
<FromGitter>
<girng> because in my example, to me, it looks like my gsub is replacing all of them with "", which isn't true. it's actually replying some with nils
<FromGitter>
<girng> but those are not printed or shown..
<FromGitter>
<girng> even when using `p`
<FromGitter>
<ezrast> no, it's replacing all of them with ""
<FromGitter>
<girng> wat, it hought they were replaced with nil, then the rest are were the blank string ("")
<FromGitter>
<ezrast> they're replaced with `nil.to_s`
<FromGitter>
<girng> which translates to = ""?
<FromGitter>
<ezrast> yes
<FromGitter>
<girng> ic
<FromGitter>
<girng> ok so the only way for gsub to work
<FromGitter>
<girng> is i need to pass in the current string it's replacing through the block
<FromGitter>
<girng> so i can return that string instead of nil ("")
<FromGitter>
<girng> correct?
<FromGitter>
<girng> how i can make it so the blocks value doesn't replace ANYTHING
<FromGitter>
<ezrast> you already know what value it's replacing, "\n"
<FromGitter>
<girng> yes but i need to return the string not a value if i want to keep it
<FromGitter>
<girng> im only trying to convert the first 10 \n's
<FromGitter>
<girng> wait, no
<FromGitter>
<girng> i mean convert the \n's after there is 10
<FromGitter>
<girng> why i use a counter
<FromGitter>
<ezrast> replacing a "\n" with a "\n" is the same as not replacing it
<FromGitter>
<girng> Ok i think i know what went wrong here
<FromGitter>
<girng> i thought i was enumerating through every WORD. of which i am not. i'm only enumerating through the \n's lol
<FromGitter>
<girng> sorry about that, thanks for your cordiality through this
rain1 has joined #crystal-lang
<FromGitter>
<girng> i also though, it would automatically return "\n" and replace the nils . which is not true (my bad). that's why i tried to just do it with a 1 liner
<FromGitter>
<girng> i also thought*
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
duane has quit [Ping timeout: 248 seconds]
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
binBASH has quit [Ping timeout: 276 seconds]
binBASH has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
<FromGitter>
<girng> ty for help asterite n ezrast
greengriminal has joined #crystal-lang
greengriminal has quit [Client Quit]
<FromGitter>
<girng> https://play.crystal-lang.org/#/r/3wpc/edit ⏎ ⏎ is this a bad way to check for the amount of linebreaks? split "makes an array" not sure if that is fine, opyrprin prob doesn't approve of this :P
<FromGitter>
<bararchy> @girng also \s = space , \t = Tab
<FromGitter>
<girng> so the each_char is better because it basically just increments a counter instead of making a whole new array and filling it
<FromGitter>
<bararchy> Yeha
<FromGitter>
<bararchy> And will work better for big Strings too
<FromGitter>
<girng> i could prob create something cool where i can just do "".mycustommethodnamehere or something?
<FromGitter>
<girng> then just call that on the string, and have it return counter orsomething
<FromGitter>
<bararchy> @girng I think string.count will also work if you use '\n'
<FromGitter>
<bararchy> As a Char
<FromGitter>
<girng> little tiny library if you will
<FromGitter>
<bararchy> Try it
<FromGitter>
<girng> oh it does work
<FromGitter>
<girng> @Givralix sorry about that, you were right
<FromGitter>
<girng> `\n` for control characters im guessing, and "" for full / real strings
<FromGitter>
<girng> \`\` i mean
<FromGitter>
<girng> '' i mean
<FromGitter>
<girng> wow, fail :D
PickleRick has joined #crystal-lang
PickleRick has left #crystal-lang [#crystal-lang]
flaviodesousa has joined #crystal-lang
alex`` has joined #crystal-lang
Ven`` has joined #crystal-lang
baweaver is now known as lemur
lemur is now known as baweaver
alex`` has quit [Ping timeout: 240 seconds]
That_Guy_Anon1 is now known as That_Guy_Anon
Ven` has joined #crystal-lang
Ven`` has quit [Ping timeout: 240 seconds]
<FromGitter>
<sdogruyol> morning
That_Guy_Anon has quit [Ping timeout: 276 seconds]
<FromGitter>
<girng> morning @sdogruyol how are u doing
<FromGitter>
<sdogruyol> fine, and you girng
<FromGitter>
<girng> very good
<FromGitter>
<girng> learning more and more crystal everyday
<FromGitter>
<girng> slow and steady wins the race
That_Guy_Anon has joined #crystal-lang
<FromGitter>
<sdogruyol> yeah, seems like you're having fun 👍
<FromGitter>
<girng> i'm breaking the conditioning of crappy core values nodejs indoctrinated me in. im sick of it
<FromGitter>
<sdogruyol> like what?
<FromGitter>
<straight-shoota> morning =)
<FromGitter>
<girng> types
<FromGitter>
<girng> there are soo many TYPES and they are all super important
<FromGitter>
<sdogruyol> morning @straight-shoota
<FromGitter>
<girng> to know which type does what. in nodejs it seems like i never knew anything besides a string or number
<FromGitter>
<sdogruyol> I feel you...I've done some Nodejs back in 0.8 - 0.10 days
<FromGitter>
<sptorin_twitter> How I can get all matches from regexp, like flag /regexp/g? For example need get all numbers from line: `"1q2w".match(/\d+/).not_nil!.to_a` - this get only first match
<FromGitter>
<sdogruyol> glad that I escaped callback hell
<FromGitter>
<girng> Agree!
Jenz has joined #crystal-lang
That_Guy_Anon has quit [Ping timeout: 240 seconds]
Jenz has left #crystal-lang [#crystal-lang]
Ven` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven`` has joined #crystal-lang
<FromGitter>
<sdogruyol> wtf...the new reddit design is so ugly..
<FromGitter>
<girng> ikr
<FromGitter>
<girng> dat popup when u click on a thread rofl
<FromGitter>
<sdogruyol> thanks god there's a rollback to old design
<FromGitter>
<girng> i only use reddit cuz programmingcirclejerk and crystal lang sub
<FromGitter>
<sdogruyol> same, just some subreddits
<FromGitter>
<girng> yeah thank goodness they let u opt out of it lol
<FromGitter>
<girng> i would be pretty mad...
<FromGitter>
<girng> well, i just wouldn't visit the site anymore. more time in sublime for crystal :D
<FromGitter>
<girng> turn negative into a positive, right!?
<FromGitter>
<girng> tfw their 2010 mobile looks better than their beta one in 2018 :rofl:
<crystal-gh>
[crystal] oprypin closed pull request #4906: Remove Crystal::System, do system-specific methods by reopening (master...no-crystal-system) https://git.io/v5le3
<crystal-gh>
[crystal] oprypin closed pull request #5003: Change Errno into a hierarchy of OSError subclasses (master...oserror) https://git.io/v5bAY
<crystal-gh>
[crystal] straight-shoota opened pull request #5972: Fix macro interpreter Number type of arithmetic expressions (master...jm/fix/5971) https://git.io/vpq1Q
<FromGitter>
<drum445> Yeah JS is pretty frustrating
<FromGitter>
<drum445> It's bad enough on the client let alone on the server lol
<FromGitter>
<girng> i'm glad i made the switch, i feel way better about myself
<FromGitter>
<girng> i do want to buy a crystal hoodie however
<FromGitter>
<drum445> If i have a models folder and one inherits from the other, unless the parent class has a name which appears first in the list it will not be able to be referenced
<FromGitter>
<drum445> For example, if asset_repo is inheriting from base_repo it won't be able to find it when the models directory is imported into the main file
<oprypin>
you're doing it wrong
<oprypin>
if something requires something, you write `require "./something"`
<oprypin>
and stop with the stupid `*` requires
<FromGitter>
<drum445> so in my asset_repo file I would require my base_repo file yes?
<oprypin>
yes
<FromGitter>
<drum445> cheers,
<livcd>
I wish JS would just die :P
<FromGitter>
<girng> i want the black hoodie from crystal's twitter iuno wher eto buy it though
alex`` has joined #crystal-lang
<oprypin>
girng, in case it wasnt clear, it's not on sale
<FromGitter>
<girng> but they were in boxes, and wrapped in plastic bags
<FromGitter>
<girng> looks like crystal devs doing a heist with em, be careful!
<oprypin>
girng, they were given to participants of a meetup
<FromGitter>
<girng> yah understandable
<FromGitter>
<girng> @oprypin i was curious since you're online i might as well ask. but since im about finished with my master game server (which sends data as json and uses `to_json`) alot. is there an alternative to that, that is faster for the regular game instance server code? it'll be running on a 15hz~ tickrate. with preferable 20, 50, or 100 users on an instance. ⏎ ⏎ i was reading about msgpack, but godot
<FromGitter>
... unfortunately doesn't have a module.
<oprypin>
msgpack, protobuf
<oprypin>
no module, too bad
lvmbdv has quit [Ping timeout: 256 seconds]
<FromGitter>
<girng> would it be insane to just send a string and separate movement code by a delimiter?
<oprypin>
yes
lvmbdv has joined #crystal-lang
<FromGitter>
<girng> hmm, maybe i can pay someone to add a msgpakc module to godot. since crystal has one. or i can try to do it myself. i already know how to compile godot from source
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<girng> yeah thing is i rrlly want to finish the game server stuff. but i know i can't be using to_json on a 15hz tick rate server can't be good
<FromGitter>
<girng> maybe it is iuno
<oprypin>
girng, this is premature optimization
<oprypin>
you're just guessing things
<oprypin>
it is indeed a good idea to have something working first
<FromGitter>
<girng> i already have it wirrten in nodejs im converting. dropping item, tick-rate for movement data, pvp, trading, looting an item, in-game chat, moving items in inventory, equipping items, updating when another player equips an item. only part is the `to_json` gonna be called on all these functions. plus the 15hz tick rate going with 10, 50, or 100 players. that is a LOT of `to_json` calls ⏎ ⏎ should i just
<FromGitter>
... finish converting it over, and use it like how my master game server is structured? then just benchmark it later?
<oprypin>
yes
<oprypin>
switching to a different json-like format will be easy
<FromGitter>
<girng> ok
Ven`` has joined #crystal-lang
<FromGitter>
<girng> @oprypin btw thx for putting up with me this far (and everyone else really), i appreciate it =]
alex`` has quit [Ping timeout: 264 seconds]
<FromGitter>
<ansarizafar> Whats ids the current status of Crystal. Is it production ready?
<FromGitter>
<asterite> No, it's always "use it at your own risk"
<wuehlmaus>
``make docs'' still does not work for me on Apple with crystal git. it used to work.
<wuehlmaus>
some openssl issues
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<drosehn> I have used crystal to write a few small programs which are being used "in production", but I wouldn't use crystal for some large project that I was just starting on.
<FromGitter>
<drum445> The release of 1.0 would make it production ready right?
<oprypin>
...
<FromGitter>
<drum445> ?
<FromGitter>
<fridgerator> I think 1.0 would just mean much fewer breaking changes
<FromGitter>
<drosehn> Well, at that point the language would be less likely to have major changes. And if there are major changes, it's more likely that they will include some way to automate the changes that you'd need to make.
<FromGitter>
<drosehn> ... that crystal-users would need to make to their own programs, that is.
aarongodin has quit []
aarongodin has joined #crystal-lang
That_Guy_Anon has quit [Remote host closed the connection]
hightower3 has joined #crystal-lang
greengriminal has joined #crystal-lang
hightower2 has quit [Ping timeout: 256 seconds]
<FromGitter>
<sdogruyol> @ansarizafar 1.0 means production-ready for all, we've some production users though
<crystal-gh>
[crystal] bcardiff pushed 1 new commit to master: https://git.io/vpmYU
<FromGitter>
<j8r> For production the main point is Tests, load and HA. - whatever you use, if you app handle this, and works for 1 day, you are good
That_Guy_Anon has joined #crystal-lang
jetpack_joe has quit []
jetpack_joe has joined #crystal-lang
<FromGitter>
<asterite> So... I'm back on track, but when trying to compile specs I get an error: error executing command: echo "#include <openssl/opensslv.h>
<FromGitter>
<j8r> yes. Joke apart, LibreSSL has a more robust security development. Thank you the OpenBSD team :-D
<FromGitter>
<asterite> Well, for now I'll just comment some stuff to continue working... but this is a bit messy, no one in mac-land should be able to work in the compiler right now
<FromGitter>
<j8r> But the macOS CI pass...
<FromGitter>
<j8r> If the specs require some libs, and you don't have them, this is normal to fail isn't it?
<FromGitter>
<j8r> Maybe you have to use homebrew
<oprypin>
asterite, just revert #5676 and let's move on
<FromGitter>
<asterite> all the time, when compiling
<FromGitter>
<asterite> I don't want to pass that
<FromGitter>
<asterite> I don't need that, because openssl on mac is useless, mac has its own crypto library (I think compatible with openssl)
<FromGitter>
<bararchy> @asterite I think it needs it for specs , because specs does SSL checks
<FromGitter>
<asterite> We could do that, or we could just put {%if !flag?(:darwin) %} around all that
<FromGitter>
<yxhuvud> or check for lib availability
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven`` has joined #crystal-lang
That_Guy_Anon has quit [Remote host closed the connection]
<FromGitter>
<drum445> Has anybody used MongoDB with Crystal?
<FromGitter>
<drum445> Everything was going well until I tried to apply sorting...
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<RX14>
@asterite macos dev just sucks
<RX14>
it's combination of two things
<RX14>
openssl and libressl provide incompatible pkg-config versions so it's impossible to support openssl and libressl using just pkg-config version queries
<RX14>
and then mac's openssl/libressl situation is just shit
<RX14>
at the end of the day I just approved that libressl PR because it worked on my machine and I stopped caring
<FromGitter>
<girng> gn c u in 5-6 hour need sleep
<crystal-gh>
[crystal] LVMBDV opened pull request #5973: Fix/4676 libressl support (master...fix/4676-libressl-support) https://git.io/vpmBb
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter>
<drum445> no stress with the order by in mongo, just sort the Array(BSON) on return
<crystal-gh>
[crystal] asterite opened pull request #5974: Add `MetaVar#defualt_value` and `MetaVar#has_default_value?` (master...feature/macro-default-value) https://git.io/vpmEf
<FromGitter>
<bew> Nice to see you back @asterite :)
Nathanaelle has joined #crystal-lang
That_Guy_Anon has quit [Ping timeout: 265 seconds]
Nathanaelle has quit [Ping timeout: 260 seconds]
<FromGitter>
<asterite> :)
<FromGitter>
<bew> You said several times in comments here and there that you wanted some changes for the language itself, did you already put all your ideas on paper (or in text for that matter) ? Or is it still some vague abstract ideas in your mind?
<FromGitter>
<bew> 'cause I'd like to know what you have in mind (I'm sure I'm not alone in that case ^^)
<FromGitter>
<asterite> I have some vague ideas, not sure how it's going to work. But it'll change the language quite a lot
<FromGitter>
<asterite> Named tuples would disappear, splat arguments will just be one one type
<FromGitter>
<asterite> No more class reopening (though we'd probably have extension methods)
<FromGitter>
<asterite> No method redefinition
<FromGitter>
<asterite> Mandatory types in method arguments and return types
<FromGitter>
<asterite> and constants
<FromGitter>
<asterite> Probably interfaces
<FromGitter>
<bew> oh wow, looks almost like another language, at least in "how it works"
<FromGitter>
<asterite> I think it's either that, or forever stick with possibly huge compile times
<FromGitter>
<asterite> Or, mmm... never decreasing compile times
<FromGitter>
<asterite> But people seem to be fine with the latter, so let's go with that option instead
<FromGitter>
<asterite> (and I think that also includes a broken type system, not sure how it can be fixed without breaking changes)
<FromGitter>
<bew> To me (but I don't know much here) it would be kinda possible to have re-usable pre-compilation of some shards for example (with a custom pre-compilation format) that could reduce compile time
<FromGitter>
<bew> but sure, having a custom everything takes time
Nathanaelle has joined #crystal-lang
<FromGitter>
<bew> or like, if some shard API is fully typed, (or partially?) the compiler could re-use a previous compilation of those methods
<FromGitter>
<bew> some shard API *method
<FromGitter>
<bararchy> @asterite I think the current features of the languge outwight the compile time issue
<FromGitter>
<j8r> Why remove namedtuple? How we will be able to have immutable hashes? Tuple will also disapear?
<FromGitter>
<bararchy> anyway, this won't happen I hope without a big discussion in the CoreDev team and the community as a whole.
<FromGitter>
<asterite> because NamedTuple exists for double splat, and in that language I imagine double splat can't exist
<FromGitter>
<bew> but the call flexibility we currently have would remain?
<FromGitter>
<asterite> I don't think so
<FromGitter>
<asterite> it will be more like other languages, like C#, which is pretty flexible
<FromGitter>
<asterite> I mean, what's the current flexibility?
<FromGitter>
<j8r> To sum up, what can be the future syntax for immutable hashes?
<FromGitter>
<bararchy> ```{"foo": 1}.freeze```
<FromGitter>
<bararchy> lol
<FromGitter>
<asterite> The question is: why do you need immutable hashes?
<FromGitter>
<asterite> And if you need them, they can just be a new data structure
<FromGitter>
<j8r> I'm generating macros based on a named tuple actually
<FromGitter>
<j8r> Symbol will be replaced by string - seems ok
<FromGitter>
<asterite> You can use hash in macros, it's the same
<FromGitter>
<asterite> Anyway, these are just ideas... I think the current language will remain like that
<FromGitter>
<j8r> What's nice in NamedTuple in my case (a CLI entirely generated by a macro) is: Symbol can't have spaces, and `{test: "string} ` is more concise than `{"test" => "string"}`. ⏎ But if I've no longer NamedTuples, it will not be a big deal to change to Hashes and add a check for spaces
<FromGitter>
<j8r> @oprypin I didn't know this, but there is no point of symbols so?
alex`` has quit [Ping timeout: 276 seconds]
<oprypin>
well what do you think the point of symbols was, not having spaces?
<FromGitter>
<asterite> bew: yes, argument forwarding is the only reason named tuple exists... but it makes APIs hard to use, because then you have to say "just look at the docs of this other function". And duplicating those methods just once isn't a big deal
<FromGitter>
<j8r> Hum maybe
<FromGitter>
<j8r> They can only be strings with no spaces, like arguments i guess?
<FromGitter>
<j8r> but I m maybe wrong, can we have named arguments with spaces?
<FromGitter>
<asterite> yes, we can
<FromGitter>
<j8r> Hum yeah indeed this is linked to symbols
<FromGitter>
<asterite> we can... it's a cute thing, probably not very useful... well, only to pass things like a hash, to avoid some memory allocation... but with that duplicate the amount of generated code :)
<FromGitter>
<asterite> so... really, there's no good use case for named tuples other than forwarding... in fact, we created them exclusively for that, but everyone understood them wrong
<Yxhuvud>
asterite: how impossible is it to unduplicate the code without cutting the feature?
<FromGitter>
<asterite> so even if the language doesn't change, maybe it would be good to remove them
<oprypin>
asterite, just fork it and hack away
<FromGitter>
<asterite> To unduplicate code I think you need runtime reflection
<FromGitter>
<asterite> oprypin :-)
<oprypin>
i kinda don't get why you want to turn Crystal into C#
<FromGitter>
<asterite> to have a language that can grow
<oprypin>
c# can grow
<FromGitter>
<asterite> yes, it's always growing
<oprypin>
good
<FromGitter>
<drum445> you lot like c#?
<FromGitter>
<eliasjpr> I always had the impression of NameTuple to be more of a borrowed concept to support functional paradigm, and to quickly define an inmutable type with a nice easy to read syntax. I personally find the following to be elegant ⏎ ⏎ ```alias response = NameTuple(error: Bool, body: String)``` ⏎ ⏎ So my question is how would someone define a mutable type besides a struct and class with no accessors? Class
<FromGitter>
<asterite> Just the same thing. Even less typing: `response.error` vs. `response[:error]`
<FromGitter>
<asterite> So we could already remove NamedTuple and Symbol :-D
<FromGitter>
<asterite> (which, like RX14 says, doesn't have much use cases, it's similar to String)
<oprypin>
it's not hurting anyone
<RX14>
oh yeah
<RX14>
thats why we have symbols again
<RX14>
for named tuple keys
<RX14>
aand thats it :P
<oprypin>
python has like 10 variations of structs and namedtuples that dont even have a performance advantage, and it's fine
<Yxhuvud>
well, they are pretty nice for my parser generator as it is nice to have a convenient way to create nonterminals without mixing them up with strings :P
rohitpaulk has joined #crystal-lang
<FromGitter>
<asterite> symbols are also used in the compiler's lexer, and they are kind of useful too
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter>
<asterite> but of course they kill any future effort to have incremental/modular compilation, because the compiler has to know all symbols out there
<FromGitter>
<asterite> maybe that's fine (and I stop musing about such things)
<FromGitter>
<bew> modular compilation could still be possible with a custom pre-compilation stage, where you'd have all the symbols needed by a module, but not yet with a number associated with it
greengriminal has joined #crystal-lang
<FromGitter>
<bew> Also, I was wondering, instead of assigning a number to a symbol, could we have symbols as String objects (read-only in ELF) and use the address of the String object to check if it's the same symbol or not?
rohitpaulk has quit [Ping timeout: 256 seconds]
<FromGitter>
<asterite> That's a good idea
<FromGitter>
<bew> cool, glad I got one :) which one?
<Yxhuvud>
I think we need to get more people to deeply understand the issues and the code involved here, as (at least for me), problems have a tendency of going away when multiple people approach the problem from different starting points. Then there are problems that don't go away (like compilation times of c++), but many do, at least for me
<Yxhuvud>
I wish I had more time :/
<FromGitter>
<j8r> Crystal will never be perfect, but the community is working hard on it - this is what Crystal is awesome
<FromGitter>
<asterite> I'd like to implement some form of meta attributes
<FromGitter>
<asterite> I saw that bcardiff proposed, and C# also has this, the ability to specify a same attribute multiple times... anyone knows what's that used for?
<FromGitter>
<asterite> Like, putting `@[Foo(x: 1)]`, `@[Foo(x: 2)]` and so on on top of a single type/method/var
<FromGitter>
<bew> I'd say, we can try, and see how it goes!
<FromGitter>
<asterite> I guess for now I'll start without that multiplicity thing, and with it not being "type-safe" (that is, you won't need to declare attributes)
<FromGitter>
<bew> so where would the custom attributes come from for your start implem' ?
<FromGitter>
<bew> I just don't get what you mean by "not being type-safe"
<FromGitter>
<asterite> Like, you can do `@[JSON(key: "x")]` on top of an instance variable, and from macros you'd do `var.attribute("JSON")` to fetch that
<FromGitter>
<asterite> but if you accidentally type `@[JSOON(key: "x")]`, that won't give a compile error saying "undefined attribute"... but the JSON mapping thing will probably give an error somewhere else
<FromGitter>
<bew> what would have been the safe way?
<FromGitter>
<asterite> at least as a start... then we could thing about declaring what attributes exist, and where
phaed has quit [Remote host closed the connection]
<FromGitter>
<bew> yeah ok, looks good :)
<FromGitter>
<asterite> Something like `@[Attribute(JSON, target: :instance_var)]` (that declares an attribute)
<Yxhuvud>
tbh, I'd prefer stuff that modifies what `property` does to be an argument to it. I'm not a big fan of annotations.
<FromGitter>
<asterite> Yxhuvud What do you mean?
<FromGitter>
<bew> oh, so the `@[JSOON(key: "x")]` attribute would raise directly saying that there is no such attribute, right?
<FromGitter>
<eliasjpr> @asterite isn’t `record` just a wrapper for `struct`? Also the NameTuple approach would allow to do something like `response[#{some_key}]` not that you cannot do that with Hashes, but inmutable hashes there do not exist
<Yxhuvud>
well [] => {}. Was writing while thinking, never a good idea
<FromGitter>
<bew> Yxhuvud: `property` is a macro, what would that expand to?
<Yxhuvud>
@bew: something that generates that can handle whatever you want the meta attributes to handle.
<FromGitter>
<bew> sorry, I don't understand what you mean
<FromGitter>
<asterite> The thing is, the serialization logic right now is generated at compile-time
<FromGitter>
<asterite> and attributes will be available to query at compile-time
alex`` has joined #crystal-lang
<FromGitter>
<asterite> so we have to store that somewhere... just adding arguments to `property` won't work
<FromGitter>
<asterite> unless we store that info at runtime... which is something that I think can't be done in this language
<FromGitter>
<asterite> plus, attributes are super generic... serialization is one thing, but I can imagine everyone will come up with really neat stuff with them
<oprypin>
asterite, how about making them feel less like one-liner hacks by moving them inside the class body?
<FromGitter>
<asterite> oprypin what do you mean? the declaration or the usage?
<oprypin>
declaration
<oprypin>
would look nice to have some way to define serialization and then call json.mapping and possibly other things to utilize it
<FromGitter>
<asterite> I'm not following
<oprypin>
ok just `@[Attribute(JSON, target: :instance_var)]; class A` -> `class A; Attribute(JSON, target: :instance_var)`
<oprypin>
something, i dunno
<FromGitter>
<asterite> And then you'd use it like `@[A::JSON]`?
<FromGitter>
<asterite> I thought about that, and it could work, yes
<FromGitter>
<asterite> But `@[JSON]` is just shorter, not sure why we'd need to add namespaces just now
<oprypin>
what
<oprypin>
oh i see what this is
<oprypin>
no i mean the usage
<FromGitter>
<asterite> Ot, it'll be like `class Foo; property x : Int32; include JSON::Serializable; end`
<FromGitter>
<asterite> that would make `Foo` serializable, and all properties in it be serializable too
<FromGitter>
<asterite> If you wanted `x` to parse/serialize from `y`, you'd do:
<oprypin>
that's what i was going for
<FromGitter>
<asterite> `class Foo; @[JSON(key: "y")] property x : Int32; include JSON::Serializable; end`
<oprypin>
that's very nice
<FromGitter>
<asterite> So much nicer than the current `JSON.mapping`
<FromGitter>
<asterite> And then you could also have `include Object::Constructor` or something like that, to define a constructor from all fields... I guess it's also useful in combination with `JSON::Serializable`
alex`` has quit [Ping timeout: 246 seconds]
alex`` has joined #crystal-lang
<FromGitter>
<asterite> Hmm... actually, I can't seem to find a way for that to work
<FromGitter>
<bew> (add custom initializer, in addition to the automatic one)
<FromGitter>
<asterite> Yes, maybe. I imagine the automatic one to just be enough. If 42 is the default age, the AutoConstructor will work once we merge https://github.com/crystal-lang/crystal/pull/5974
<FromGitter>
<bew> @asterite I would do you autoconstructor that way though: https://carc.in/#/r/3wt6 (no idea why there's thats yntax error)
<FromGitter>
<asterite> though I don't know how to make it work with positional arguments
<FromGitter>
<asterite> it doesn't work because the macro must be expanded to a correct program
<FromGitter>
<asterite> but it can't be done
<FromGitter>
<asterite> you'd have to put that inside a `macro finished`, I think... or something like that
<FromGitter>
<bew> oh yeah sure, shit
<FromGitter>
<asterite> but even then it doesn't work because when that's reached, the type of instance vars aren't computed yet
<FromGitter>
<asterite> Maybe differing `macro finished` a bit... I don't know...
Nathanaelle has quit [Read error: Connection reset by peer]
Nathanaelle has joined #crystal-lang
<FromGitter>
<eliasjpr> > Matz: I really, really hope so, and Vlad's work looks pretty promising. We set some criteria for Ruby 3x3, one of which is that we don't want use an existing JIT library; LLVM or something like that, because we don't control those things. Their API might change, or the project may be abandoned. Another criteria for the 3x3 project was to be as portable as possible, which is kinda difficult. You know, the
<FromGitter>
<bew> @RX14 I thought we needed 2 core reviewers even when a core dev makes the PR (to allow to have at least 2 other pairs of eyes on the changes)
rohitpaulk has quit [Ping timeout: 256 seconds]
duane has quit [Ping timeout: 240 seconds]
That_Guy_Anon has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]