C as Structural and Block-structural language
Block-structural language (BSL)- Its the special kind of structural language, that supports subroutines inside routines e.g. writing functions inside the function.
Now as a C-programmer, I want to debate on C as SL and BSL. There is no doubt that C is a SL as it supports routines in form of functions, but then experts varies on decision, whether C is a BSL or not.
I am not an expert who should propose any new theory, but I just want to put my points on discussion.
By definition of BSL (function within function), of course C has visible lack of such property, so no wonder many denies to put C in the category of BSL.
But C supports one very common property, compartmentalization of code inside the code compartment i.e. code blocks. Code blocks are not just the pack of code written inside curly braces, but it has certain characteristics too. A code blocks are independent and hides the implementation from outside. It can also define the local data, those can be accessed only inside the block and whose scope ends with the code block. Also, a code blocks can define a local static member, that possesses all the characteristic of the static data member of the function.
In other words, a code block has all the properties that a function has, except is "anonymous". So, C is a block structural language. Lets push C in BSL.
Here a contradiction occurs. By definition, a function is a named identity that accepts some argument(s) and returns a result. An anonymous function officious lacks that property. So calling a code block, a function within function, is not completely true. That pops C back from BSL.
But, here we are talking definitions, definitions of SL, BSL, function & anonymous function.
Oops, I missed the definition of anonymous function. Lets me put it, "an anonymous function is a special kind of function that has no name, that takes no argument and returns nothing".
Well, that means, a code block is not a function or rather say, its not a pure function but an anonymous function, but never the less, its still is a function. So, C supports property of BSL, function within function. So, once again C is BSL. Then, lets push C again in BSL.
Also, if we are talking about definition, then SL does not talk about the existence of the function at all, but it only says about existence of routines. So, whether a named or anonymous function a code block is, its a routine. So, if C is a structural language, then it must be a block-structural language too.
|