- From: Tab Atkins Jr. via GitHub <sysbot+gh@w3.org>
- Date: Fri, 07 Jun 2019 20:35:49 +0000
- To: public-houdini-archive@w3.org
> A feature of Sass that is really useful in custom functions is the ability to return null to indicate that no return value is desired A custom function could return an empty [CSSUnparsedValue](https://drafts.css-houdini.org/css-typed-om/#unparsedvalue-objects) to indicate that it finished correctly, but just didn't output anything. > But custom functions really need them as an intermediate value to allow custom functions to interoperate. Can you give some example use-cases? > Can trailing arguments be made optional? Can optional arguments be assigned a default value? Currently no, you have to predeclare your arity. (Like custom paint() functions, you provide an array of grammar strings, which are interpreted as the grammars for comma-separated arguments.) Or declare your grammar to be "*", which opts out of parsing entirely so you can do something more complicated on your own. This is something we'll fix over time, definitely, and apply it to all the Houdini function things. > The ability to lazily evaluate input arguments, is required to implement something like conditional execution. You need lazy eval in JS (and I assume Sass) because running code can have side effects. Side-effects aren't possible in this model tho. You can absolutely implement a conditional, but it would be akin to the JS trinary operator. > So that authors can write generic code that is correctly typed, it seems like there should be some concept of a type generic. Note that, at least for now, custom functions don't have typed output - they're a JS-controlled `var()` function, and thus can output anything, and that output is then parsed alongside the rest of the stuff in the property value. The output does have to be a Typed OM value, but that includes CSSUnparsedValue, which is the output type of `var()`. Is there thus still a need for generics? -- GitHub Notification of comment by tabatkins Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/857#issuecomment-500029977 using your GitHub account
Received on Friday, 7 June 2019 20:35:51 UTC