How to resolve the algorithm Null object step by step in the COBOL programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Null object step by step in the COBOL programming language
Table of Contents
Problem Statement
Null (or nil) is the computer science concept of an undefined or unbound object. Some languages have an explicit way to access the null object, and some don't. Some languages distinguish the null object from undefined values, and some don't.
Show how to access null in your language by checking to see if an object is equivalent to the null object.
This task is not about whether a variable is defined. The task is about "null"-like values in various languages, which may or may not be related to the defined-ness of variables in your language.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Null object step by step in the COBOL programming language
Source code in the cobol programming language
identification division.
program-id. null-objects.
remarks. test with cobc -x -j null-objects.cob
data division.
working-storage section.
01 thing-not-thing usage pointer.
*> call a subprogram
*> with one null pointer
*> an omitted parameter
*> and expect void return (callee returning omitted)
*> and do not touch default return-code (returning nothing)
procedure division.
call "test-null" using thing-not-thing omitted returning nothing
goback.
end program null-objects.
*> Test for pointer to null (still a real thing that takes space)
*> and an omitted parameter, (call frame has placeholder)
*> and finally, return void, (omitted)
identification division.
program-id. test-null.
data division.
linkage section.
01 thing-one usage pointer.
01 thing-two pic x.
procedure division using
thing-one
optional thing-two
returning omitted.
if thing-one equal null then
display "thing-one pointer to null" upon syserr
end-if
if thing-two omitted then
display "no thing-two was passed" upon syserr
end-if
goback.
end program test-null.
You may also check:How to resolve the algorithm Sum multiples of 3 and 5 step by step in the Q programming language
You may also check:How to resolve the algorithm Catamorphism step by step in the Raku programming language
You may also check:How to resolve the algorithm Textonyms step by step in the Io programming language
You may also check:How to resolve the algorithm Shell one-liner step by step in the Burlesque programming language
You may also check:How to resolve the algorithm Bitmap/Read a PPM file step by step in the J programming language