'several pages of "if x = 1..." through "if x = 77..." statements. ' ...
that seems typical of COBOL code that I happened upon.

"The more verbose the better" was its apparent motto.

M



On 11/12/2019 17:10, 'Jim Russell' via Programming wrote:
Thanks, and of course.
Mine was a knee jerk reaction to some COBOL code long ago from a young programmer who, having not yet 
mastered the intricacies of a "go to depending on" clause, instead had several pages of "if x 
= 1..." through "if x = 77..." statements.

On Dec 11, 2019, at 11:09 AM, Raul Miller <[email protected]> wrote:

https://www.jsoftware.com/help/dictionary/csel.htm

But, also, https://www.jsoftware.com/help/dictionary/d520.htm and
https://www.jsoftware.com/help/dictionary/d621.htm

But it's usually not wise to make efficiency claims which are not
supported by benchmarks.

And, benchmarks tend to be specific to workloads and implementation
versions (with a plausible exception when the timing differences
exceed a factor of 2).

Thanks,

--
Raul

On Wed, Dec 11, 2019 at 11:05 AM 'Jim Russell' via Programming
<[email protected]> wrote:

Yes but...
I'd contend that a string of tests is usually less efficient than (perhaps 
calculating) some numeric value that is amenable to a case statement. ( I 
should have checked first; J does have a case statement, does it not?)

On Dec 11, 2019, at 10:32 AM, Henry Rich <[email protected]> wrote:
Yes.

Henry Rich

On 12/11/2019 5:46 AM, 'Mike Day' via Programming wrote:
So is it still ok in J9 - and will it be ok - to continue using the following 
paradigm?

if.     T  do. B
elseif. T1 do. B1
elseif. T2 do. B2
end.

Thanks,

Mike


On 11/12/2019 10:23, Henry Rich wrote:
else. after elseif. is new in 9.01, and you found a bug in it.

JfC is for J6.02.

Henry Rich

On 12/10/2019 8:23 PM, Ben Gorte wrote:
Hi,

Despite repeated warnings in JforC I stepped into the trap of using elseif.
and else. in the same if.-statement. It took some effort to find that
error, because the behaviour is kind of weird:

  iftest =: 3 : 0
if. y=1 do.
   echo 'one'
elseif. y=2 do.
   echo 'two'
elseif. y=3 do.
   echo 'three'
else. NB. should be elseif. do.
   echo 'other'
end.
)

    iftest 1
one
other
    iftest 2
two
other
    iftest 3
three
    iftest 4
other

Wouldn't it be possible to have that working like expected? Or elseif do
flag an error?

Greetings,
Ben
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to