#Seeking Opinions on Default Value Support in Named Parameter Feature

1 messages · Page 1 of 1 (latest)

leaden lantern
#

Hi everybody, this is the JPlus development team.

The point we would like to discuss is whether to support Default Values.

Option A: Named Parameter only

  • Pros: Simpler syntax, minimal implementation and learning overhead
  • Cons: Call sites may become longer in some situations

Option B: Named Parameter + Default Value

  • Pros: More concise code, allows omitting some arguments when calling
  • Cons: Can make code slightly harder to read if too many defaults are used

We would like to gather opinions on whether default values are truly necessary in practical coding scenarios.

weary pilotBOT
#

<@&987246399047479336> please have a look, thanks.

fiery badger
#

gonna say, this has some weird aftertaste of being an advertisment in disguise

slim viper
#

Don't generate boilerplate, code should not always be the same.

edgy mica
#

the main pro of named parameters over new Record(a, b).with { c = ...; d = ...; } is that you can handle a large number of non-optional params

#

so that is their unique pro

#

A general complaint i have is that it really doesn't seem like you have thought this through beyond syntax

#

like with Lombok (a different Java++) it seems like there is not just "all the same things", but the same things in the same way

leaden lantern
# edgy mica Named Parameters are nearly always used in contexts with a lot of default values

First, I would like to thank Ethan McCue for his valuable feedback. I agree that the usefulness of named parameters is limited to situations such as constructors or object initializations with many default values. I also appreciate your comment regarding boilerplate code generation, noting that there isn’t a significant difference compared to Lombok. We will take this into consideration to further improve JPlus. We look forward to your continued interest in the JPlus project.

edgy mica
#

don't say "we" if its just you

#

it comes off strange

leaden lantern
slim viper
#

Look more and more like an ads.

fiery badger
#

maybe u post this in #1150852739467849829 instead and move the discussion over to the github itself?

#

the part that lets this look like an ad-in-disguise are all the extra paragraphs and links that are technically irrelevant to the (ofc totally valid) question itself

leaden lantern
# fiery badger <:peepo_shrug:1320114464393003188>

Thanks for the suggestion! That makes sense. I wanted to provide context for anyone unfamiliar with JPlus, but I can see how the extra links and paragraphs might make it look like self-promotion. I’ll consider moving the discussion to GitHub and keeping posts here more focused on the question itself.

tall yoke
#

Yeah I looked at this the other day but I really dont see why I wouldn't use lombok instead?

#

the syntax is very intrusive with the whole apply {} block thing

#

so what about lombok? uwu

misty moon
fiery badger
#

^^ nothing wrong with promoting (open source) projects btw, that's why we have #1150852739467849829

#

but yeah

#

shouldnt be done in a weird way, leaving a sour aftertaste