Hello Corey,

on elif
 if misplaced elif
    misplaced elif error
    eval expression
      => possible eval error
    set new status if eval fine

Currently it is really:

  switch (state) {
  case NONE:
  case ELSE_TRUE:
  case ELSE_FALSE:
     success = false;
     show some error
  if (success) {
    success = evaluate_expression(...);
    if (success) {
       switch (state) {
       case ...:

Which I do not find so neat. The previous one with nested switch-if-switch looked as bad.

The issue at hand being the benefit to the user vs code complexity.


One of my point is that I do not really see the user benefit... for me the issue is to have no user benefit and code complexity.

The case we are discussing is for the user who decides to write code with *two* errors on the same line:

  \if good-condition
  \elif bad-condition

with an added complexity to show the elif bad position error first. Why should we care so much for such a special case?

Maybe an alternative could be to write simpler code anyway, somehow like it was before:

  // on "elif"
  switch (peek(state)) {
  case NONE:       error;
  case ELSE_TRUE:  error;
  case ELSE_FALSE: error;
  case IGNORED:    break;
  case TRUE:       poke IGNORED;
  case FALSE:
                   success = evaluate(&is_true)
                   if (!success)
                   else if (is_true)
                       poke TRUE
  default:         error;

The only difference is that the evaluation is not done when it is not needed (what a draw back) but ISTM that it is significantly easier to understand and maintain.

Now if you want to require committer opinion on this one, fine with me.


Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to