|
Pascal doesn't have classes, but defining local functions within an outer function is the common practice. If you see PROGRAM as a little more than a PROCEDURE with global initialization, every function/procedure that you write lies inside another function/procedure(/program).
You probably see great advantages of hiding some matters local to a class within that class inside the class definition. In Pascal, you would hide helper functions for a larger function inside that larger function - just like you have local variables and data structures. Also note that in Pascal, a parameterless function was called just by its name, with no empty ()s. So you could change a simple variable to a function calculating the value, without making changes to the code using it. (It took several decades before C# got properties, to do the same!) If I change a local simple variable to a calculated, but still local, value, I see no major reason for why I should have to move the declaration of it out to the global level.
During my student days, we migrated from Pascal to C, requiring all functions to be declared in a flat space. Also, the convention of creating a separate file for each function, even a three-line one, was introduced. What was a nice, closed set of a major function / procedure and its helper functions, was spread out all over the place. You couldn't use a simple editor search function to find definition and all its uses (calls) - you had to use an external 'search files' function, outside the editor. (Our editors at that time did not have a built-in 'search files'.) We did use a lot of hardcopy printouts of source code in those days, and having to print even a 3-line function as a separate file, on separate sheets, increased the amount of paper by a large factor. By Unix/C standards, conventions required a lot of formal blurb (copyleft etc.), as well as inclusion/processing of sometimes huge header files, which in turn lead to number of #ifdefs and stuff like that. In Pascal, a 3-line function was no more than a 3-line function, declared in the scope where it was used, just like the variables. Old Pascal programmers did not see C as any great progress ...
There is no principal difference between classes within classes or functions within functions. The arguments for using or not using it is the same.
One major argument against nested procedures/functions was related to Pascal visibility rules: The tiniest, innermost function doing the simplest helper function had access to all its own local variables, of course, but also everything in the enclosing function, and everything at the next outer level and so on all the way out to the program global variables and functions / routines.
Languages with static nesting was quite common in the 1970s and 80s, and it was used frequently used. (Ask someone learning compilers in those years to explain what a 'static link' is - maybe you'll learn something new!). To handle the issue of the innermost little helper function having the greatest access, to 'everything', some languages required you to export symbols not only to the outside, but also to the inner functions, and the inner functions to import them. (To reduce clutter, some languages let you export/import 'pervasively', so that no further import/export was required for the next levels.)
After shelving Pascal, I have not used much function nesting - for a couple decades, it wasn't possible in C based languages, so I got out of the habit. I cannot recall a single case of nested class definitions. But when I learned of C#, properties and accessors, I became a heavy user of that - which is certainly related.
Religious freedom is the freedom to say that two plus two make five.
|
|
|
|
|
I do, but the embedded classes are always marked private - they are only accessible within the containing class.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
yeah, no private at all listed...
it doesn't help that VS2022 has some of the most ridiculous compiler errors. One error typically generates N other gripes.
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
Every time I've embedded classes inside another class, some new requirement down the road requires I remove this embedded class and make it stand on its own.
I will occasionally put two classes in a file, especially when one is the <type t=""> for a custom collection class. The collection class is usually very short (<40 lines) and I put it at the top of the file so both classes are visible on the first screen in the IDE.
|
|
|
|
|
happy to see it's not just me.
The only two times I have seen this style, they both came from CS grads whiz kids. I'm now going through a lot of code from WK#1 where he forgot to initialize a bunch of variables.
Side note: I know VS2022 allows you to ignore uninitialized variables, but why in God's good name would you ever turn that off? Been burned to many times by everything working in debug and phantom failures in release.
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
Statement 1: Every rule has an exception.
Statement 2: Statement 1 is a rule. Therefore Statement 1 has an exception.
Conclusion: There is at least one rule which has no exception.
Would you agree with this conclusion? If so, is there any example of a rule having no exception?
|
|
|
|
|
Friends don't let friends program in Basic.
If you can't find time to do it right the first time, how are you going to find time to do it again?
PartsBin an Electronics Part Organizer - Release Version 1.4.0 (Many new features) JaxCoder.com
Latest Article: EventAggregator
|
|
|
|
|
Kurt Gödel proved a version of Statement 1:
In any formal language, there are questions that can be asked but not answered.
A perfect example of Gödel's incompleteness law can be found in math:
- Positive Integers (lengths) can subtract a larger number from a smaller number. The answer is a negative integer, leading to:
- All integers can divide and result in a fraction, leading to:
- Fractions can be used in geometry to result in real numbers, leading to:
- Real Numbers can have square roots that are imaginary, leading to:
- Complex numbers, etc...
|
|
|
|
|
|
In a certain village, a barber shaves all those who do not shave themselves. Who shaves the barber?
"A little song, a little dance, a little seltzer down your pants"
Chuckles the clown
|
|
|
|
|
Behind every paradox lies a Cretan.
Religious freedom is the freedom to say that two plus two make five.
|
|
|
|
|
Wordle 1,045 2/6
⬛⬛⬛⬛🟩
🟩🟩🟩🟩🟩
|
|
|
|
|
Wordle 1,045 4/6
⬜🟨🟩⬜⬜
🟨🟩🟩🟨⬜
🟩🟩🟩🟨⬜
🟩🟩🟩🟩🟩
|
|
|
|
|
Wordle 1,045 3/6
⬜⬜🟩🟨⬜
⬜🟩🟩⬜🟩
🟩🟩🟩🟩🟩
|
|
|
|
|
Wordle 1,045 4/6
🟨⬜⬜⬜⬜
⬜⬜⬜🟨🟨
⬜⬜🟩🟨🟩
🟩🟩🟩🟩🟩
|
|
|
|
|
Wordle 1,045 3/6
⬛⬛🟩🟨🟩
⬛🟩🟩⬛🟩
🟩🟩🟩🟩🟩
Jeremy Falcon
|
|
|
|
|
Wordle 1,045 3/6*
🟨🟩⬜⬜⬜
🟨🟩🟩⬜⬜
🟩🟩🟩🟩🟩
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Wordle 1,045 4/6*
⬜⬜🟩🟨⬜
🟨🟩🟩⬜⬜
⬜🟩🟩🟨⬜
🟩🟩🟩🟩🟩
Happiness will never come to those who fail to appreciate what they already have. -Anon
And those who were seen dancing were thought to be insane by those who could not hear the music. -Frederick Nietzsche
|
|
|
|
|
🟩🟩🟩⬜⬜
🟩🟩🟩⬜⬜
🟩🟩🟩🟩🟩
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
Wordle 1,045 4/6
🟨⬛⬛⬛⬛
⬛🟩🟩⬛🟩
⬛🟩🟩⬛🟩
🟩🟩🟩🟩🟩
Ok, I have had my coffee, so you can all come out now!
|
|
|
|
|
Wordle 1,045 3/6
🟩🟩⬛⬛🟩
🟩🟩⬛🟩🟩
🟩🟩🟩🟩🟩
WordleBot
Skill 74/99
Luck 74/99
If you can't explain something to a six year old, you really don't understand it yourself. (Albert Einstein)
|
|
|
|
|
Thunderbird has been my SMTP client for years. My problem may be Thunderbird related, but my gut feeling says that it is not ...
I have several times noticed, when fetching new mail, that the status line says: 'Retrieving message 4 of 12', or something like that. When it completes, there are far less than 12 new messages in my inbox.
Tonight, it retrieved 'x of 6 messages', but only a single new message was in my inbox. There is nothing in the Thrash (and when something goes to Thrash, a counter displays the number of new entries). If a filter had redirected the messages to some other folder, it would have been seen in new count for that folder. Anyway, I have looked through every single folder, without finding anything new.
This is a fairly new thing; I have noticed it for a few weeks. Can anyone explain what is happening? Why does Thunderbird report 6 messages and display only 1 to me? I am suspecting that someone are trying to check if my mail address is valid, possibly also to see if I am reading the mailbox, by sending messages which somehow is marked to be deleted immediately, or possibly at a specific point in time that is already past - but I wasn't aware that SMTP had such a feature.
For the sender to be notified that I have received the mail, I am aware of an SMPT option for that. Thunderbird has several times presented a dialog box telling that the sender has requested a confirmation that the message has been received, with buttons for 'Return confirmation' and 'Do not send confirmation'. I have seen nothing of this when messages are 'missing'. I wasn't aware of an SMPT option for 'silently' generating a read confirmation - does it exist? If it exists, can it be used to secretly 'ping' me, the way it appears to me now?
Is there some other possible explanation? Could it be a Thunderbird hiccup? (That is a strange hiccup!)
Religious freedom is the freedom to say that two plus two make five.
|
|
|
|
|
Duplicates in 'All Mail' and Important ? I've seen that happen, but didn't pay attention to the message count.
|
|
|
|
|
I do not have, nor can I remember ever having an 'All Mail' and 'Important' folder. Searching in the TB help information, it seems as if it may be related to IMAP mail servers - my connection is via pop3. Some entries about 'All Mail' also seem to relate it to gmail, but gmail is not my mail provider; I use online.no, a mail service run by the Norwegian phone company.
Any further proposals?
Religious freedom is the freedom to say that two plus two make five.
|
|
|
|
|
Maybe try thunderbird forums / support.
|
|
|
|
|