Skip to content

Commit 0a3e41f

Browse files
committed
doc changes
1 parent b0dda83 commit 0a3e41f

File tree

1 file changed

+26
-11
lines changed
  • manifold-deps-parent/manifold-params

1 file changed

+26
-11
lines changed

manifold-deps-parent/manifold-params/README.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
> **⚠ Experimental**
1+
> ** Experimental Feature**
22
33
# Optional parameters & named arguments
44

@@ -164,19 +164,34 @@ Optional parameters and named arguments preserve three essential aspects of bina
164164
- **Binary accessible**
165165
- **Java standard compatible**
166166

167-
### Backward compatible
168-
Adding new optional parameters to existing methods is binary compatible with code compiled before the new parameters were added.
167+
### Backward compatible
169168

170-
For example, this method:
169+
You can add new optional parameters to existing methods without breaking compatibility with code compiled before those
170+
parameters were introduced.
171+
172+
**For example:**
173+
Suppose you have the following method:
171174
```java
172-
public void size(int width) {...}
173-
```
174-
Could be updated with an optional height parameter:
175+
public void size(int width) { ... }
176+
```
177+
You can update it to include an optional `height` parameter:
175178
```java
176-
public void size(int width, int height = width) {...}
177-
```
178-
Code compiled with the previous version still works without requiring recompilation.
179-
179+
public void size(int width, int height = 0) { ... }
180+
```
181+
Code compiled with the earlier version of the method will continue to work without requiring recompilation.
182+
183+
**Changing Default Values:**
184+
If the default value of an optional parameter changes, the updated value will apply even when older code calls the method.
185+
```java
186+
public void size(int width, int height = width) { ... }
187+
```
188+
In this case, older code that doesn’t specify a `height` argument will use the new default (`width`) at runtime without
189+
needing to recompile.
190+
191+
**⚠️ Caution:**
192+
Changing default values, while binary-compatible, can still impact the behavior of existing code. Make these changes
193+
cautiously to prevent unintended side effects.
194+
180195
### Binary accessible
181196
Optional parameters and named arguments are fully accessible from compiled .class files, just like source code.
182197
```java

0 commit comments

Comments
 (0)