Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8248699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:16:49+00:00 2026-06-07T23:16:49+00:00

I have a procedure which performs some task, but performs it in two slightly

  • 0

I have a procedure which performs some task, but performs it in two slightly different ways depending on its input. Specifically it extends a suffix in a suffix tree; if the suffix ends at a node the case is simple, but when the suffix ends within a leaf edge some additional work is required. I mention this detail to explain why I have included these two behaviours in a single function (it mirrors “Rule 2” of Dan Gusfield’s description of Ukkonen’s algorithm for suffix tree construction: http://www.stanford.edu/~mjkay/gusfield.pdf).

Anyway, once the function completes this work, the caller needs to know which of the two cases were followed. I thought an enum would be a good way to share this information, as it makes the cases explicit (as opposed to arbitrarily mapping the cases to bools or ints).

TLDR: To share information with the caller, should I pass an enum by reference to this procedure or return an enum? I feel like passing an enum by reference is better because it avoids having a ‘function with side effects’ but would like to know if there is generally ‘right’ way of doing this. Or, alternatively, does this really suggest that I should be replacing my single procedure with two separate procedures?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:16:52+00:00Added an answer on June 7, 2026 at 11:16 pm

    In my opinion it makes more sense to return the enum, since it is the result from calling the function. Using a reference would make much more sense if you were passing a value to the function, and the function was supposed to modify that value.

    You can see a similar example in insert method from unordered_map in the C++ standard library:

    template <class P> 
    std::pair<iterator, bool> insert( P&& value );
    

    That method returns a boolean (within a pair) stating whether the value was inserted in the map or not. This actually a very similar case as the one you are dealing with.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have inherited a stored procedure which performs joins across eight tables, some of
I have a stored procedure, which performs a database backup for a specific database.
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
I have a procedure which uses 2 sql databases - this is required in
I have a stored procedure which update a table based on such calculation and
I have a stored procedure which returns sys_refcursor and I am trying to fetch
I have a stored procedure which accepts a User defined table type called SeasonTable
i have a procedure in which i am inserting record in employee table.nad getting
I have a stored procedure which takes an XML parameter and inserts the data
I have a stored procedure which returns a ref cursor as follows: CREATE OR

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.