-
-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[shader-ast] Better design for defn
with anonymous qualified arguments
#441
Comments
Can you please provide a more concrete example of what you're proposing here? I'm not sure I follow... if this is just to avoid having to give a name for args when also wanting to specify its // current
export type Arg<A extends Type> = A | [A, string?, SymOpts?];
// maybe could be...
export type Arg<A extends Type> = A | Pick<SymOpts, "q" | "num" | "prec"> & { type: A, id?: string }; Then use in situ like so: defn("float", [{q: "in", type: "float", num: 4}], (x) => [...]) |
I expect something like
|
And also, simple type like |
@sylee957 Thank you for all these thoughts, but may I please ask a question here: What is your general use case for this library? I'm just genuinely super curious, since you've been filing a ton of issues in a very short amount of time and mainly about aspects I'd personally consider pretty specialized (not necessarily edge cases, but definitely aspects I've rarely needed in the 4.5 years since this project started). E.g. case in hand here: The times I've required defining function args with options was only when working with arrays args or a handful of cases with Also, related, there're features (like support for structs and uniform blocks) I definitely would like to support and have attempted several times in the past, but always got stuck by getting into super complex type constructs and generics nightmares before giving up again. In those situations, I often come to the conclusion that my time is better spent on more useful things... at least until there's a more obvious way forward. Lastly, I also want to stress once more that GLSL (and its semantics/details) is always just gonna be one (if currently still the main) target of multiple others and 100% feature parity with GLSL was never the aim. This coming year I want to focus more on WebGPU/WGSL — so please do keep these aspects in mind here too... |
Unfortunately, I'm unclear about the interest or roadmap about the project, after hearing this comment though. Sadly, I don't think that there is much competitor projects in implementing shader languages in Javascript. |
@sylee957 I think you're very much misreading my previous comment: "My time being better spent" referred to my own previous attempts to add struct & UBO support, absolutely NOT regarding your efforts... I was (still am) genuinely interested in learning more abour your use case(s), since it would help me to better understand how you're intending to use this package (and what for). Some of the changes & syntax features you address are great for general completeness, but I've been trying to explain in your various issues a) why certain things are not there (yet) or are currently implemented differently than what you propose (e.g. template literal types discussion in #438 ) and b) I'm always cautious about spending too much precious time on things with dubious ROI, since each of these additions also means increased long term maintenance effort (usually on my end). I believe these are all fair points, but obviously you beg to differ... it's also why I've been repeatedly asking you to provide a bit more context about your own interest/usage of this project. I've not said "no" to any of your points, just please understand that this package is just a small fragment of a much larger undertaking and there's a need to first experiment with some of these proposals (to get a better "feel" for them) before comitting to them. Some of the things in question are quite fundational (but also subjective/opinionated) changes (e.g. the above proposed arg handling) and so please understand that I need to ask for more context (or have different views) and/or need more time to think about wider implications of some of these proposals. None of these things should imply disinterest and I apologize if this is what you took away from this.... |
I’m doing studies of how to supplement all the knowledges I have about typescript, functional programming, object oriented programming, dependent types, |
I just observe that the signature of
defn
is a bit messy to work in practice, for some reasons:And making them anonymous is often better because I don't want to repeat names, one for javascript variable identifier and the other for shader
(
const myfunc = defn(..., 'myfunc', ...)
, ordefn(..., [['float', 'x'], ['float', 'y']], (x, y) => {})
out
orinout
, are much more useful, especially if I have to port some code that someone have made, or if I have to work around to avoidstruct
.Although I can around the issue by implementing some 'helper' for
defn
, however, I wonder the better design of the signature could be:defn(type: Type, args: Arg<Type>[], body: (...Arg<Type>[]) => Term[], name?: string)
where it has advantages
_args.map(defArg)
expose factory likedefArg
as user API. I think that it is better for deciphering the types if we expect user to make objects homogeneously.undefined
ornull
positionally if they want anonymous functions or variables.The text was updated successfully, but these errors were encountered: