Discussion:
OBNC equivalent of C's va_list
(too old to reply)
Hưng Gia
2020-03-06 07:52:56 UTC
Permalink
It seemed OBNC doesn't understand the "..." like GNU Modula-2.

https://www.nongnu.org/gm2/interface_to_c.html

How could I use libc's function like printf, which take a variable number of arguments?
miasap
2020-03-07 19:04:35 UTC
Permalink
Post by HÆ°ng Gia
It seemed OBNC doesn't understand the "..." like GNU Modula-2.
https://www.nongnu.org/gm2/interface_to_c.html
How could I use libc's function like printf, which take a variable number of arguments?
OBNC implements only the features in the language report, which means
that the number of parameters for a given procedure is fixed.


-- Karl
Hưng Gia
2020-03-08 07:13:33 UTC
Permalink
Post by miasap
Post by HÆ°ng Gia
It seemed OBNC doesn't understand the "..." like GNU Modula-2.
https://www.nongnu.org/gm2/interface_to_c.html
How could I use libc's function like printf, which take a variable number of arguments?
OBNC implements only the features in the language report, which means
that the number of parameters for a given procedure is fixed.
-- Karl
Many libraries make use of variable argument list. If I want to create a binding for Oberon to work with ONBC, how could I implement it? Or I have used Oberon wrong all the time, that Oberon was designed to be a standalone language and everything should be done on Oberon alone and interfacing to other libraries not needed? I think Oberon is a general purpose language and want to do GUI in Oberon, so I plan to create a binding for GTK+. I don't know if I could accomplish this job but the first show stopper is va_list. Another problem is I have to doubled the work. First to write an Oberon module then having to edit the generated C source which is the the actual binding. So I asked if we could make it easier to use a header like solution, .def file as GNU Modula-2 does, to simplify the process? So I only have to write the .def file once then just use it.

It seemed my proposal would not accepted because you followed a guide line so you can't introduce new extensions and I was wrong to think Oberon is a general purpose language, it should be considered as a special purpose language.

-- Hưng
miasap
2020-03-08 10:20:50 UTC
Permalink
Post by HÆ°ng Gia
Many libraries make use of variable argument list. If I want to
create a binding for Oberon to work with ONBC, how could I implement
it? Or I have used Oberon wrong all the time, that Oberon was
designed to be a standalone language and everything should be done on
Oberon alone and interfacing to other libraries not needed? I think
Oberon is a general purpose language and want to do GUI in Oberon, so
I plan to create a binding for GTK+. I don't know if I could
accomplish this job but the first show stopper is va_list.
Variadic functions in C break type safety. That's one of the reasons
there is no similar feature in Oberon.
Post by HÆ°ng Gia
Another problem is I have to doubled the work. First to write an
Oberon module then having to edit the generated C source which is the
the actual binding. So I asked if we could make it easier to use a
header like solution, .def file as GNU Modula-2 does, to simplify
the process? So I only have to write the .def file once then just
use it.
Mapping Oberon procedures directly to C functions can only be done in
some cases. For instance, a C function can return a character pointer
but an Oberon procedure cannot. Moreover, if you pass a non-terminated
string to an Oberon procedure which is implemented in C you can catch
the invalid parameter with an assertion. If the C function is called
directly the program will probably crash.


-- Karl

Loading...