0 Followers
0 Following
2 Posts

Argument datatype dependant of previous arguments?

https://lemmy.world/post/2697004

Argument datatype dependant of previous arguments? - Lemmy.world

While working with a dynamically typed lang, I came across this: hash(password, algorithm, algorithmOptions) Where algorithm is a constant signaling which hashing algorithm to use, and algorithmOptions is a dict whose keys depend on algorithm. So I thought, can we dictate that if a previous parameter has this value, then this parameter has to have this other value? E.g. enum HashAlgo { Bcrypt, Argon2, } type BcryptOptions = { Int optionA, Int optionB, } type Argon2Options = { String optionC, String optionD, } // Here I make this type "depend" on an argument of type HashAlgo type HashOptions = [HashAlgo] => { HashAlgo::Bcrypt => BcryptOptions, HashAlgo::Argon2 => Argon2Options, } fun hash( String password, HashAlgo algorithm, // Here I use HashOptions, passing the prev. argument HashOptions[algorithm] options, ) This way the compiler can ensure the correct dict is used, based on the value of algorithm Does something like this exist? I now realize that it would be impossible to type check in compile time based on a runtime value, but if it was allowed only for constants? What do you think?

Are transfer speeds tied to internet speed?

https://lemmy.world/post/2327222

Are transfer speeds tied to internet speed? - Lemmy.world

When i connect to my jellyfin server to stream/download video/audio the speeds are tied to my internet speed. If my internet speed drops so does the transfer rate from my server. However it seems tied to my internet download speed (which varies from 0.5 to 80 mb/s), not the upload speed(which is usually 2 mb/s), and if i disconect my router from the internet I’m able to react the maximum allowed by my hardware. Is this normal? Or maybe something is wrong, or needs special configuration? If relevant, I connect to a tp link router, which connects to the router from my isp.