104 Replies
Unknown UserOPā¢10mo ago
Message Not Public
Sign In & Join Server To View
remap + sift + immut
and maybe the spread operator, why not
Unknown UserOPā¢10mo ago
Message Not Public
Sign In & Join Server To View
noes, immutability means that if you change the values, you need to create a new one with your changes, but if for example, you have PlayerData, and inside you have Settings
if you change settings, you'd need to duplicate PlayerData and Settings, but SomethingElse should stay the same, you just add it back as it is in your new PlayerData table
so, it's not quite the same as a deep-copy
Unknown UserOPā¢10mo ago
Message Not Public
Sign In & Join Server To View
what is the code
Unknown UserOPā¢10mo ago
Message Not Public
Sign In & Join Server To View
yeah this is not gonna work
this is a nested table
even if you spread it, you are still editing the Slot and then Coins
so it's still mutating
I might recommend immut for this case
i wouldn't recommend immut to roblox-ts user
elaborate
immut is horrible
what
how
then spread 5 times
nested
if you use any syntax that generates non-draft save functions inside drafts (spread operators, macros, etc) it will generate code with an UB
use remap or spread operator
make dispatchers
it's not that bad compared to immut
what is non-draft save functions
table.insert, table.clone, etc..
Im not even gonna talk about macros
bruh
macros like push generate those functions
ooohhh
so, e.g. you do
draft.arr.push(1) and ur cookedthat is expected
it's a skill issue
how you'd call it horrible
and that is.. HORRIBLE to debug, believe me
what
no
never got that problem
you just shouldnt do it
that's it
xD
the whole purpose of immut is to produce immutable snaps by state mutations
and well.. you say i shouldn't do it
š
why use immut then
I mean, yeah it's a bad idea to recommend immut for this case, when the guy doesnt know how immutability works yet
because nesting table.clones
is awful
spread operators, remap, sift
you name it
ok you're recommending using a library for the whole purpose of setting stuff via indexations
when you need to change something deeper
it's a pain
you could simply write a utility function that does just that..
how
without the need for something as bug-prone as immut
explain
idk anything like
set(state, "tbl1", "tbl2", "tbl3", value) (it's possible to make type-safe)is it really that hard to remember not to use array methods?
that will clone the objects recursively
not array methods
spread operator does the same
you basically strip any roblox-ts functionality by using immut
so why use it
why would you use spread operators?
you already use immut for that
patching for example:
why would you use immut for patching
why are you arguing
like
you just need to know how the library works
and then it's very easy to use
for what
you need to internalize it
for the purpose of doing
a.b.c = 3
that's the only thing u can with this library in roblox-tsyes, and editing maps maybe
dude, make a utility function
though you have remap for that
remap does just that
it's so error-prone, buggy and useless i don't know why one would even consider it
how that is buggy
it just has limitations
like everything
because if you use a non-draft safe function
it won't warn you
it will just produce code that does not work
it's easily error-prone
and it sucks
you said it sucks, thus you've never used it
I use it a lot, never had a problem with it
lmao
how is your opinion more valid here?
i used it, and not doing that anymore after debugging why the f*ck my players lose data from time to time for a couple of days straight
i'm going to beef with every immut user after what i've been through
well, you'll eventually get better
either with immut, or immutability in general
or eventually you'll get better at making design decisions and what to use
yeah that's the point
it's just a tool, it's not gonna magically solve immutability
which was probably what you expected
though, you still don't understand why are you using it for the sole purpose of doing
a.b.c = 3
why not a utility function
why use something as error-prone as thisyes, and relative operators like += and that
and for combining a.b.c when c is then a map
and so on
still not good enough reasoning for me
it's funny how
you can do certain macros and they work just fine
like map.get() or map.set(), obviously, because they don't produce harmful emit
but why one would even consider immut
for no real benefit
why even bother learning all this through pain n ass
for what
i don't get it
learning what, it's not that complicated lol
you just listed all the edge cases when it fails
spread operator, array methods, filter
that's all
if "edge cases" for you is using default macros that everyone utilizes in their code daily
and u think that's ok
i don't know what to say to you
if you need to use filter or the macros
you then use sift
ok first

why use sift if those macros are immutable in the first place
its not like spread operators are easier to read tbh
like, this is harder to reason with
and this is just a single property
i'm not opposed to using sift
I didnt even know that when you marked an array as readonly, the macros were still there, just with an immutable version
i'm opposed to using immut
that's so bizzarre tbh
??
wtf
macros are immutable even with regular arrays
i don't know what you're saying
oh ya they have some
it has
move which is weird
anyway, I still prefer to use Sift with immutable arrays, doesnt matter if there is a macro that works with immutable data
it's just weird, and I dont even mark my interfaces with readonly
plus, modifying accidentally an immutable state is a bug harder to find, than trying to manipulate the draft
the latter is a lot more obviousthis argument is invalid
it's your fault for not typing your state as immutable properly
I just have immutability already internalized
even my thoughs are immutable
use a filter macro and stop gaslighting yourself into immut being good
i did that a while ago, and i'm happy ever since
well, Im also happy ever since I used immut
:DD
ur reality isn't real
u live in the matrix
it's an illusion of happiness
:D
just like immut
it lies to you
immut's whole point is to lie to you
you just need to be better than immut
faster
it gaslights you into thinking ur state can be mutated safely
but you secretly know that's not true
that's why it cant trick you
yes, but evil nonetheless
a lie is a sin
immut is made and distributed by devil
Unknown UserOPā¢10mo ago
Message Not Public
Sign In & Join Server To View
it does work
but it doesn't help the problem
Unknown UserOPā¢10mo ago
Message Not Public
Sign In & Join Server To View
yes and that's dogshit because it doesn't match ts api
Unknown UserOPā¢10mo ago
Message Not Public
Sign In & Join Server To View
it doesn't match ts api (which is array.push) and it doesn't help the problem in the first place
the problem is it being error-prone
Unknown UserOPā¢10mo ago
Message Not Public
Sign In & Join Server To View
alternative:
set(obj, "field", "something", 2)Unknown UserOPā¢10mo ago
Message Not Public
Sign In & Join Server To View
no, but i'm pretty sure it's possible to make it type-safe, lemme try to make that up
ok i half-assed this by taking replica-service types but u get the point
Playground link
Posted by <@343061601831616522>
it could probably be a separate package if someone wanted to
Unknown UserOPā¢10mo ago
Message Not Public
Sign In & Join Server To View
wtf
huh
I think you should learn how to work with immutable data, or, do something else, otherwise its gonna be a pain
lapis can be worked mutably
but the roblox-ts types are still immutable
Unknown UserOPā¢10mo ago
Message Not Public
Sign In & Join Server To View


this how you would with Sift
sift has a Sift.Dictionary
the other one is with the spread operator
Unknown UserOPā¢10mo ago
Message Not Public
Sign In & Join Server To View
seems correct

with immut you could just edit it as it is
but I'd agree with wad
it's not a magical solution and if you are not careful, it could be a footgun simulator
Playground link
Posted by <@342788489831645184>