View Poll Results: What naming convention should be better for libgba for freepascal?

Voters
10. You may not vote on this poll
  • Original libgba naming convention

    1 10.00%
  • Pascal naming convention

    9 90.00%
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: LibGBA naming convention

  1. #1

    LibGBA naming convention

    The library for gba coding I released was a bit raw, so I have made a new (and more complete) port, translating libgba to pascal, and packaging it for freepascal. Now I have a little dilemma: should I follow pascal naming convention (making everything more understandable for pascal people) or should I let original libgba names (making easyer to understand existing c tutorials and code for gba)?
    EG.: now I have code like
    [pascal]// original libGBA naming convention
    type bg_scroll = record
    x: u16;
    y: u16;
    end;
    ...
    function BG_PALETTE(m: integer): integer;
    [/pascal]
    but maybe should be nicer (and more readable)
    [pascal]// pascal naming convention
    type TBgScroll = record
    x: u16;
    y: u16;
    end;
    ...
    function BgPalette(m: integer): integer;
    [/pascal]

    Any suggestion will be very appreciated
    Get your fpc4gba copy now!
    Get your fpc4nds copy now!

  2. #2

    LibGBA naming convention

    I think you should stick to the pascal naming convention. I don't think it will casue problems with C to pascal conversion and it would be consistent with other freepascal libraries. It is just a matter of remembering that C type names will be prefixed with 'T', pointers to them with 'P' and no underscores. And last (but not least ) I think that
    Code:
    type TBgScroll = record
      x: u16;
      y: u16;
    end;
    ...
    function BgPalette(m: integer): integer;
    is prettier than
    Code:
    type bg_scroll = record
      x: u16;
      y: u16;
    end;
    ...
    function BG_PALETTE(m: integer): integer;

  3. #3

    LibGBA naming convention

    If it were a port for own use only, I'd personally keep the original convention; makes tranlsating and finding bugs heaps easier.

    Though if you don't mind too much, it would be better, and look nicer overall in a pascal convention.

  4. #4
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    LibGBA naming convention

    I'd say go with Pascal. Odds are it'll anyone using it will break away from the C-based tutorials and conventions rather soon anyways.

    Just don't pooch the capitalizations, if you're gonna use 'em. I find that really fustrating to work with. It also makes the library look sloppy imo.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  5. #5

    Re: LibGBA naming convention

    I think normal "JEDI" convention is to keep the origional definitions but to declare Pascal style ones

    [pascal]

    type bg_scroll = record
    x: u16;
    y: u16;
    end;
    TBGScroll = bg_scroll;
    PBGScroll = ^TBGScroll;

    [/pascal]

    Functions are declared in normal Pascal style though.
    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

  6. #6

    Re: LibGBA naming convention

    Quote Originally Posted by technomage
    I think normal "JEDI" convention is to keep the origional definitions but to declare Pascal style ones

    [pascal]

    type bg_scroll = record
    x: u16;
    y: u16;
    end;
    TBGScroll = bg_scroll;
    PBGScroll = ^TBGScroll;

    [/pascal]

    Functions are declared in normal Pascal style though.
    Uhm... yes, this could be a good solution
    Get your fpc4gba copy now!
    Get your fpc4nds copy now!

  7. #7

    LibGBA naming convention

    There are two groups of Pascal coders, people_that_underscore_their_identifiers and PeopleThatIniCapsTheirIdentifiers. There is no preferred convention for Free Pascal, as long as a single unit is reasonably uniform.

    What we do not really appreciate is ALL_UPPERCASE identifiers. If there is a need to highlight parts of the code there exists syntax highlighting. Lastly, please do not invent your own typenames. While names like u8, s8, u16 are not necessarily a bad idea, people do not like it if a type in one unit is named differently than the same type in another unit.

    Be care of variables that contain a memory address, they should not be converted to cardinal or u32, but to a pointer, or if an integer type makes more sense, ptruint.

  8. #8

    LibGBA naming convention

    Quote Originally Posted by dmantione
    There are two groups of Pascal coders, people_that_underscore_their_identifiers and PeopleThatIniCapsTheirIdentifiers. There is no preferred convention for Free Pascal, as long as a single unit is reasonably uniform.
    IAmThisKindOfPascalCoder :mrgreen:

    What we do not really appreciate is ALL_UPPERCASE identifiers. If there is a need to highlight parts of the code there exists syntax highlighting.
    In fact I hate this kind of highlighting too. I have let all uppercase for const values only (that seems to me "pascalish" enough)

    Lastly, please do not invent your own typenames. While names like u8, s8, u16 are not necessarily a bad idea, people do not like it if a type in one unit is named differently than the same type in another unit.
    Be care of variables that contain a memory address, they should not be converted to cardinal or u32, but to a pointer, or if an integer type makes more sense, ptruint.
    These typenames are let to be more consistent with existing documentation about gba programming. According to memory region where a variable is written, I need a different data type to write, in order to prevent strange behaviours. However I have tryied to make a consistent data types usage in different units.

    I'm not sure I have understood the stuff about memory locations. EG. this one:
    [pascal]
    VideoBuffer : ^u16 = pointer($6000000);
    [/pascal]
    is the only way I have found to write u16 data starting from memory address $6000000. :think:
    Get your fpc4gba copy now!
    Get your fpc4nds copy now!

  9. #9

    LibGBA naming convention

    Quote Originally Posted by Legolas
    Lastly, please do not invent your own typenames. While names like u8, s8, u16 are not necessarily a bad idea, people do not like it if a type in one unit is named differently than the same type in another unit.
    Be care of variables that contain a memory address, they should not be converted to cardinal or u32, but to a pointer, or if an integer type makes more sense, ptruint.
    These typenames are let to be more consistent with existing documentation about gba programming. According to memory region where a variable is written, I need a different data type to write, in order to prevent strange behaviours. However I have tryied to make a consistent data types usage in different units.
    Well, I don't want to force anything on you, so please do what you feel is right. However, please look at the big picture. For example in Pasjpeg, as 32 bit signed integer is called int32. In Paszlib it was called sint32, etc. Of course nothing is wrong with a simple longint.

    I'm going to kill all of this in the FPC sources, because this introduces nothing but chaos. Paszlib is already done, Pasjpeg is on the todo list.

    Quote Originally Posted by Legolas
    I'm not sure I have understood the stuff about memory locations. EG. this one:
    [pascal]
    VideoBuffer : ^u16 = pointer($6000000);
    [/pascal]
    is the only way I have found to write u16 data starting from memory address $6000000. :think:
    This is completely acceptable. I meant you should avoid code like this:
    [pascal]
    var video_location:cardinal;

    begin
    video_location:=$6000000;
    [/pascal]

    Better is:
    [pascal]
    var video_locationtruint;

    begin
    video_location:=$6000000;
    [/pascal]

    However, a pointer is what you should aim for:
    [pascal]
    var video_locationointer;

    begin
    video_location:=pointer($6000000);
    [/pascal]

    Generally, I think we should enable the absolute variables for the GBA. I.e. the compiler supports this:
    [pascal]
    var videobuffer:array[0..$ffff] of byte absolute $6000000;
    [/pascal]
    This construction is accepted for Dos only, because Dos was until now the only OS where this made sense. However, it would be a very good idea to enable it for the GBA as well.

  10. #10

    LibGBA naming convention

    Quote Originally Posted by dmantione
    Well, I don't want to force anything on you, so please do what you feel is right. However, please look at the big picture. For example in Pasjpeg, as 32 bit signed integer is called int32. In Paszlib it was called sint32, etc. Of course nothing is wrong with a simple longint.

    I'm going to kill all of this in the FPC sources, because this introduces nothing but chaos. Paszlib is already done, Pasjpeg is on the todo list.
    No problemo! I can remove it from library, letting those data types to the private use, if someone is comfortable with it.

    Quote Originally Posted by dmantione
    Generally, I think we should enable the absolute variables for the GBA. I.e. the compiler supports this:
    [pascal]
    var videobuffer:array[0..$ffff] of byte absolute $6000000;
    [/pascal]
    This construction is accepted for Dos only, because Dos was until now the only OS where this made sense. However, it would be a very good idea to enable it for the GBA as well.
    Yes, I requested it some times ago. It is cleaner than assigning pointer to consts here and there too
    BTW, do you think that activating absolute for gba could be a feasible task for me? :think:
    Get your fpc4gba copy now!
    Get your fpc4nds copy now!

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •