Eliot Miranda wrote:


On Thu, Dec 15, 2011 at 2:14 PM, Igor Stasenko <siguctua@gmail.com> wrote:
On 15 December 2011 10:28, Henrik Sperre Johansen
<henrik.s.johansen@veloxit.no> wrote:
> On 14.12.2011 02:10, Igor Stasenko wrote:
>>
>> On 14 December 2011 01:17, Fernando Olivero<fernando.olivero@usi.ch>
>>  wrote:
>>>
>>> Igor, is this a bug?
>>>
>>> When parsing methods that send native functions withouth arguments ,
>>> void, theres a DNU.
>>> For example in the following method:
>>>
>>> ^ self pangoCairoNbCall:#(PangoCairoFontMap
>>> pango_cairo_font_map_get_default ( void ) )
>>>
>>>
>>> I fixed it like this:
>>>
>>> usesMethodArguments
>>> "first check wether my single argument is void"
>>> ^(fnSpec arguments size = 1 ==>  [fnSpec arguments first class ~=
>>> NBVoid]) and:[ fnSpec arguments anySatisfy: [:type | type loader
>>> usesSTStack ] ]
>>>
>>>
>> Well, the function signature syntax are not strictly following C.
>> Just use empty parens for functions with no arguments. This is quite
>> archaic C syntax, which is really not important to support.
>>
>> Or i can add this patch if you insist. :)
>
>
> So you would say f.ex.
> http://david.tribble.com/text/cdiffs.htm#C99-empty-parm
> is incorrect?
>

in what context we're talking about? if this declaration in C code,
then of course it could mean that it does not defines the arguments
yet.
But if we speaking about signature of function for callout, then i
think it is clear what it stands for.

Are you?  Since in C () means an unspecified argument list this could be the way of declaring a varargs function, e.g.

printf: arguments
    <cdecl: printf ()>

could insist on arguments being an array and automatically marshall all the elements in it.


I had thoughts about adding handling the sole 'void' keyword in
function params, but then i thought, what the heck, it doesn't makes
creating callouts harder or easier. Unlike from C/C++ code it carries
no additional functional load. Nothing.

> Cheers,
> Henry

Best regards,
Igor Stasenko.

best,
Eliot

Just wading into a topic I don't know much about... (but hey! thats how I learn....)
I did do some reading around and [1] is the best related article I found.

I first want to check how the discussion has been framed in separating the prototype definition from the function call.  I assume there is a <cdecl...> prototype  "pango_cairo_font_map_get_default(void)" somewhere near the call code which is not shown.  This I believe would be correct to include the void definition as per [1].  The original code snippet appears to be the function call.  This I believe should not include void as a parameter.

Now if I had another external library function prototyped with one parameter - something like "<cdecl int foo (int)>"  and I called it with two integer parameters, what would be the error message?  Would it be "incorrect number of parameters" or just DNU ?  As a naive user I would expect the first. The latter would be more scary and discouraging.

Perhaps an "incorrect number of parameters" error would cover the scenario of void being included with a function call, since before you evaluate the "void" it might look like a parameter where none is expected. (this said without really knowing yet how that call process works in detail, but hopefully the general idea is there)

[1] http://stackoverflow.com/questions/693788/c-void-arguments

cheers, Ben