tomhrr / dale

Lisp-flavoured C
BSD 3-Clause "New" or "Revised" License
1.03k stars 48 forks source link

Why do function pointer type argument lists need names for the types? #131

Closed porky11 closed 6 years ago

tomhrr commented 7 years ago

This was only because it made parameter type parsing simpler, with the same code being used in all cases. It has now been made more flexible in the function pointer case.

porky11 commented 7 years ago

But if the old way of defining functions is still possible, what if I write this (fn int ((p int)))? Will the argument be a (p int) or a int with name p? Only allowing one version (with or without names) by default may be the only non-confusing solution. Without names we don't have unneccessary code, but existing code using function pointers with names will have to be rewritten, with names the syntax will be more uniform (which is not helpful, if the names will only confuse) If only one version is implemented, the other version could also be implemented as macro. having to write (p (fn …)) instead of (fn …) also seems unneccessary. May it be possible some time that functions are used directly, or would (fn …) also make sence to use for function pointers?

tomhrr commented 7 years ago

That's a good point, regarding the ambiguity. At least in some cases, it's helpful to be able to give parameter names in the type, and I don't think placeholder names (a, b, c, ...) are very misleading in the other cases, so for the time being it will be reverted.

The p in (p (fn ...)) is technically unnecessary, because it's not possible to have a variable that points to a 'bare' function. However, omitting it would make it an exceptional case compared with all other pointer types, so I think it's worth having.