hhvm / hack-codegen

Library to programatically generate Hack code and write it to signed files
https://hhvm.github.io/hack-codegen/
MIT License
341 stars 93 forks source link

Support renderers for args in addMultilineCall #68

Open simonwelsh opened 6 years ago

simonwelsh commented 6 years ago

For our current use of addMultilineCall, it's fairly common to pass literals as arguments, including nested arrays. Would be nice if we could use HackBuilderValues::export() rather than having to do it manually.

fredemmott commented 6 years ago

I'm not sure how to design this in a way that works reasonably well for both all-args-have-same-renderer and different-renderer-per-arg.

It might be best to add a HackBuilderValue type which includes both a T and a IHackBuilderValueRenderer<T>, and take multiple hackbuildervalues

fredemmott commented 6 years ago

This is probably worth looking at v5, which hopefully won't be as long away as v3 => v4 :)

lexidor commented 1 year ago

Waking this issue from its multi year slumber. My instinct says: Why not both?

Keep the current addMultilineCall() around, since requiring a builder for a true literal would be cumbersome. Add a new method which takes on builder and apply it to all arguments.

I am not sure a third version taking builder+value pairs would be much more convenient than using the builders at the call site. There is no need to add this in the same PR, so that may/might be postponed (indefinitely?).