Menu

#1 Singelton Interface

open
nobody
None
1
2005-05-26
2005-04-26
No

Might I suggest implmenting a singelton type interface
here rather than passing around an agi structure. The
can only be one agi structure per program, so forcing
the user to pass it around is unnecessary.

There are several ways you could do this. You could
have a global pointer to the agi stuff that is
initilized when the user initilizes the agi stuff, and
each function could use this global pointer instead of
making the user pass it one.

Just a suggestion.

Discussion

  • Matthew Nicholson

    • labels: --> 723981
    • priority: 5 --> 1
     
  • David Cornewell

    David Cornewell - 2005-05-26

    Logged In: YES
    user_id=765158

    You are absolutely correct in your statement. However, I
    have developed habits from programming in multi threaded
    environments. I have a personal problem with global
    variables. While you are correct in saying that a single global
    will not cause any problems, but I would feel dirty doing it. I
    may look into setting up some macros and having it return a
    structure rather than being passed one. That would save a
    little typing, but I think this is a minor thing. If I get any spare
    time to work on this I will probably finish adding support for
    the rest of PHPAGI's features.

    Thank you for the comments. I have moved this in to a
    feature request. I didn't see any bug here. Let me know if
    there is so I can move it back.

     
  • David Cornewell

    David Cornewell - 2005-05-26
    • labels: 723981 -->
     
  • Matthew Nicholson

    Logged In: YES
    user_id=287248

    Well I don't know the best way to do a singleton in c, but I
    imagine you could also use a function with a static
    variable/structure for the agi stuff too. But it is as you
    said mostly a cosemetic tweak.

     

Log in to post a comment.