News for hackers. Stuff that matters.
Re:Be wary of functions which take several parameters of the... by toyg on Thursday September 26, 2019 @08:38PM (#21087303)
Yeah, I was just showing that in Python keyword arguments are first-class in every respect, which is not that common.

The "JS solution" for example is not a solution, but only a convention: the actual interface is just expecting an object, and there is no explicit check on the validity of such object or its contents. That is nowhere near "strongly typed", if anything it's weaker than average.

Re:Be wary of functions which take several parameters of the... by thelazydogsback on Thursday September 26, 2019 @08:56PM (#21087431)
> The "JS solution" for example is not a solution, but only a convention: the actual interface is just expecting an object,

Well if it uses de-structuring syntax, then it can be type-checked.

Re:Be wary of functions which take several parameters of the... by tomjakubowski on Thursday September 26, 2019 @09:59PM (#21087715)
De-structuring syntax isn't required, this is just as easily type-checked:

    interface CopyArgs {
        src: string;
        dst: string;
    }

    function copy(args: CopyArgs) {
        exec(["cp", args.src, args.dst])
    }
Re:Be wary of functions which take several parameters of the... by thelazydogsback on Friday September 27, 2019 @12:13AM (#21088342)
Sure, if you want to get all interfacy - but pretty soon it'll be Java :)
Re:Be wary of functions which take several parameters of the... by davedx on Friday September 27, 2019 @07:16AM (#21090613)
Hah I thought that initially, but TypeScript interfaces are simpler (and usually co-sited) compared to their OO cousins. I find them a pleasure to use.
Re:Be wary of functions which take several parameters of the... by RobertKerans on Friday September 27, 2019 @01:52AM (#21088851)
It can, manually (as it can for a non-destructured object), but it has no typing guarantees - the function will still happily be interpreted and run as long as _any_ object is given as an argument.