• OBNC equivalent of C's va_list

    From =?UTF-8?B?SMawbmcgR2lh?=@21:1/5 to All on Thu Mar 5 23:52:56 2020
    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?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From miasap@21:1/5 to All on Sat Mar 7 20:04:35 2020
    On 2020-03-06 08:52, Hưng Gia wrote:
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?B?SMawbmcgR2lh?=@21:1/5 to All on Sat Mar 7 23:13:33 2020
    Vào 02:04:36 UTC+7 Chủ Nhật, ngày 08 tháng 3 năm 2020, miasap đã viết:
    On 2020-03-06 08:52, Hưng Gia wrote:
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From miasap@21:1/5 to All on Sun Mar 8 11:20:50 2020
    On 2020-03-08 08:13, Hưng Gia wrote:
    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.

    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)