Forum OpenACS Development: Use of inline functions in package creation scripts
create function inline_0 () returns integer as' begin perform acs_object_type__create_type( ''forums_forum'', ''Forums Forum'', ''Forums Forums'', ''acs_object'', ''forums_forums'', ''forum_id'', ''forums_forum'', ''f'', null, ''forums_forum__name'' ); return null; end;' language 'plpgsql'; select inline_0(); drop function inline_0();As you don't do anything with the return value here, I wonder what's the reason for the use of that inline function. As a counter-example here's how Jeff does it in his Photo Album:
select content_type__create_type ( 'pa_album', -- content_type 'content_revision', -- supertype 'Photo album', -- pretty_name 'Photo albums', -- pretty_plural 'pa_albums', -- table_name 'pa_album_id', -- id_column null -- name_method );I'm not saying these old scripts should be changed, since it doesn't harm anyone if they use inline functions. I'd just want to point out that you don't have to use inline functions in order to call another function unless you a) need to use the return value of that function later, or b) need to call that function in a loop for many entries.
If I haven't understood something totally wrong, that is
This methodology is unfortunately also being promulgated in the development tutorial for oacs here. There is generally little reason to create an inline function if it already exists and can be called directly as demonstrated by Jeff in his photo-album as you point out and by Lars in lars-blogger just to name two examples.
There's absolutely no need to do this, as has been pointed out, and our docs shouldn't suggest it. You only need to do it if you need the result of one function call to pass as a parameter to another function.
I'd like to help work on a best practices manual over the summer but until 5.0 is out most of our core folk won't have time, I know.
Would you like to take over the Do and Don't FAQ? I will give them to you if you want.
Not sure. But the Do's and Don't was geared towards developers with some experience with OACS. Even some of the oldies would get some info out of it. I made this up so we can finally have a definitive guide. I think it was supposed to make it in 4.6.x but I think it was such an odd ball that it never made it. So I guess maybe you can get it and see where it is best to put it into the docs. So it finally goes in.
One of the reasons I stopped maintaining it actively because feedback slowed down. It is likely since its only liked in this forums. Much of the knowledge on this forums are buried after a while. Since its coming up again, why not finally put it into the docs or something.
For example when I played around with the postgres version of the logger I just looked at other code and found the somewhat peculiar-looking stuff with inline functions. Not having a real clue of Postgres I just took up on that trick...