[Info-vax] DCL's flaws (both scripting and UI)
Stephen Hoffman
seaohveh at hoffmanlabs.invalid
Thu Jan 22 17:24:42 EST 2015
On 2015-01-22 21:30:48 +0000, mcleanjoh at gmail.com said:
> It's just simpler and usually clearer to write Loops (FOR, WHILE, DO)
> instead of chunks of DCL that don't have something like ...
Or with objects and enumeration...
NSString *keyString;
for (keyString in someDictionary) {
NSLog(@"Key: %@, Value %@", keyString, [someDictionary
objectForKey: keyString]);
}
That block of code declares keyString, which is a pointer to a unicode
string, and then performs a for enumeration which repeatedly calls
NSLog(...) for each entry present in the someDictionary dictionary
object. The dictionary is a key-value store, and it's been acquired
from or loaded from earlier code.
The NSLog(...) displays both the keyString and the matching value for
the key fetched from the someDictionary dictionary object. (The @"Key:
%@, Value %@" string is the Unicode formatting string for the NSLog
logging request that prints the requested data to the output device,
and the %@ bits within that string are placeholders for Unicode strings
that are fetched from the two parameters to the call.
There's no need to explicitly include the loop incrementation nor the
loop limit logic, as the run-time can trivially determine those details
by querying the someDictionary object.
If I wanted to upcase the strings retrieved from the someDictionary
object, the [someDictionary objectForKey:keyString] stuff shown above
would be replaced with something like [[someDictionary
objectForKey:keyString] uppercaseString]. For example:
NSString *keyString;
for (keyString in someDictionary) {
NSLog(@"Key: %@, Value %@", keyString, [[someDictionary
objectForKey:keyString] uppercaseString]);
}
Yes, somebody did have to write the enumeration, the code to manage the
dictionary and its allocated memory, and the code used to fetch the
length from and the code used to increment through the object. But in
terms of what I have to include to program this same sequence on VMS,
this'd all require rather more code if written in DCL, BASIC or C on
VMS.
--
Pure Personal Opinion | HoffmanLabs LLC
More information about the Info-vax
mailing list