veryl icon indicating copy to clipboard operation
veryl copied to clipboard

Default argument of function

Open dalance opened this issue 1 year ago • 3 comments

#1164 introduced default argument of function too, but I think more consideration is required.

  • Ambiguous position of default argument

In the following case, calling FuncA(0, 0) is ambiguous. It may be i_a = 1, i_b = 0, i_c = 0 or i_a = 0, i_b = 1, i_c = 0. To prevent this issue, the restriction that default arguments should be placed at last may be required.

function FuncA (
    i_a: input logic = 1,
    i_b: input logic = 1,
    i_c: input logic,
) {}
  • Lower explicitness

At module instantiation, port names are shown, and it is clear which ports are omitted. But at function, argument names are not shown, so explicitness is lower than module instantiation. Forbidding default argument may be reasonable as the same as Go / Rust.

dalance avatar Jan 03 '25 10:01 dalance

@taichi-ishitani I think temporarily disabling this feature for v0.13.4 is better. How about it?

dalance avatar Jan 03 '25 10:01 dalance

@taichi-ishitani I think temporarily disabling this feature for v0.13.4 is better. How about it?

I agree with you. I will open a PR for this.

taichi-ishitani avatar Jan 03 '25 14:01 taichi-ishitani

@taichi-ishitani I think temporarily disabling this feature for v0.13.4 is better. How about it?

I agree with you. I will open a PR for this.

I opened PR #1181 for this.

taichi-ishitani avatar Jan 03 '25 15:01 taichi-ishitani