Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Minor API inconsistencies

This thread is locked; no one can reply to it. rss feed Print
Minor API inconsistencies
Polybios
Member #12,293
October 2010

1) I have noticed some functions that are meant to query a boolean property are named al_is_* while some are called al_get_*.
I've checked whether those following the al_get_* pattern have corresponding al_set_* functions (as it might be nicer to have al_get_*/al_set_* than al_is_*/al_set_*), but that wasn't alyways the case.

The ones that are called al_get_... without corresponding al_set_... colleagues are:

  • al_get_timer_started

  • al_get_joystick_active

  • al_get_haptic_active

  • al_get_sample_instance_attached

  • al_get_mixer_attached

  • al_get_audio_stream_attached

The ones with corresponding setters are:

  • al_get_thread_should_stop

  • al_get_voice_playing

  • al_get_sample_instance_playing

  • al_get_mixer_playing

  • al_get_audio_stream_playing

2)
Another very minor API inconsistency concerns the "platform specific functions":
All of them seem to follow an (unusual) al_-platform-_verb_...-pattern (e. g. al_osx_get_window), but one exception:
al_get_win_window_handle.
Note that the D3D/OpenGL functions, too, follow the al_-verb-_opengl_* and al_-verb-_d3d_* patterns respectively.

Thus, the only function names that don't follow the al_verb_...-pattern are:

  • "platform specific functions" - except al_get_win_window_handle

  • al_ustr_*, al_utf8_*, al_utf16_*, al_ref_*, al_cstr

  • al_color_*

  • file I/O, memory management and fixed point maths are different beasts anyway ;)

I thought I'd post it here for comments.

By the way: The prototype for al_do_multiline_text is mysteriously absent from the docs page. How do I resurrect it?
Edit: Nevermind, the culprit was a space in addons/font/text.c:544.

SiegeLord
Member #7,827
October 2006
avatar

Thanks for going through those! Some of those are indeed poorly named, and could stand for a revision. I think we'll be able to start deprecating some of the worst names in the next stable release. I've added this thread to my TODO list.

Polybios said:

Edit: Nevermind, the culprit was a space in addons/font/text.c:544.

This is now fixed.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Yodhe23
Member #8,726
June 2007

Talking of inconsistencies...
why is

al_fgets(file,buffer,size)

different to

fgets(buffer,size,file)

??

www.justanotherturn.com

Thomas Fjellstrom
Member #476
June 2000
avatar

Because we didn't want to clone the original libc api. Its more important for allegro's api to be consistent with itself than with similar external APIs. Allegro tends to go with the object it is operating on as the first parameter.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Chris Katko
Member #1,881
January 2002
avatar

Because we didn't want to clone the original libc api.

While that's true, it's slightly confusing we copy the function name, but not the argument ordering.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

jmasterx
Member #11,410
October 2009

Maybe a macro would be useful:

#define al_fgets_t(b,s,f) al_fgets(f,b,s)

Go to: