Hi Seb,

2009/9/14 Sebastien Lelong <[email protected]>:

>> 1- As you [Richard] describe: format puts the output in a buffer and a user
>> always calls a function to output this buffer to a device. This means
>> most user have to make two calls.

>> 3- To always call the output function. When you don't want the output,
>> pass a dummy var. Also, documenten how to access the formatted string.

> I don't understand why you want to change current behavior.
This would be option 3 - the call to the format procedure will also do
the actual output.

> Ideally "format" should formats and return a structure representing that
> format, which could be then used by "print".
That would be option 1 - the result of a format call is a filled buffer.

> That way you refactor the
> formatting code in "format", and use these functions in "print".
Please not!
Print takes care of outputting vars. The output format is determined
by the procedure name and the value passed. Ideal to dump info on a
serial port etc.

Format  gives you ultimate control of the output format. It support
fixed point formats and makes sure it does take the exact number of
chars you tell it to. Not more and not less. Ideal to place info on an
lcd or in columns (or menu) on a terminal.

Calling format through print will increase the number of parameters
(and program size) of print procedures and hence break the api (we
don't have overloaded procedures...). A bad idea imo.

> In any cases, try not to blow up current API :)
Well. That's option 3 again...

If we however value the api, we could do both:

A- a new set of formatting functions that fill the buffer, like:

    _format_byte_dec(byte in data, byte in n_tot, byte in n2)

B- the current format api that calls the functions that fill the
buffer (A) and then call the output functions like:

   procedure format_byte_dec(volatile byte out device, byte in data,
byte in n_tot, byte in n2) is
       _format_byte_dec(data, n_tot, n2)
       _format_print(device)
   end procedure

If we intend to do so, we have to define (A) as inline and add stubs:

    procedure format_byte_dec(byte in data, byte in n_tot, byte in n2) is
       _format_byte_dec(data, n_tot, n2)
   end procedure

(the examples are from old format.jal and might change a bit )

Joep

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to