Click here to Skip to main content
15,910,471 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
raddevus19-May-24 6:22
mvaraddevus19-May-24 6:22 
JokeRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
Nelek19-May-24 10:19
protectorNelek19-May-24 10:19 
GeneralRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
Mike Hankey19-May-24 10:41
mveMike Hankey19-May-24 10:41 
GeneralRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
trønderen19-May-24 11:58
trønderen19-May-24 11:58 
GeneralRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
Richard Andrew x6419-May-24 12:13
professionalRichard Andrew x6419-May-24 12:13 
GeneralRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
trønderen19-May-24 12:11
trønderen19-May-24 12:11 
GeneralRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
Ralf Quint20-May-24 10:14
Ralf Quint20-May-24 10:14 
GeneralRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
trønderen20-May-24 14:44
trønderen20-May-24 14:44 
Ralf Quint wrote:
you have multiple records/objects with the same names for data (of the same TYPE) or methods/procedures/functions, you can not be sure which one might be called/referred to.
You have exactly the same problem with instances of a class definition (i.e. objects): When you read the code in the class methods, you cannot know which instance, which object, is being manipulated.

A Pascal "with" isn't very good at hiding it: "with SomeObject do ..." sort of identifies SomeObject as the one being manipulated, doesn't it?

I cannot remember ever listing multiple variables the way you do - it seems like you are doing it specifically to create a problem - one that isn't there, if you follow the Pascal line of thought. Let me construct another example:
Pascal
procedure P;
  var C: integer;

  procecdure Q;
    var C: integer;
    begin
      C:= 1;
    end;

  begin
    { some other code }
  end;
The "C:= 1;" - which C does it refer to? The one declared in Q or the one declared in P? No Pascal programmer would be in doubt.
Let's now write
Pascal
with A do
  with B do 
  begin
    C:= 1;
  end;
Is it difficult to see whether the "C:= 1;" refers to B.C or to A.C? No Pascal programmer would find it difficult!
Pascal
with A, B do
is just a short form of
Pascal
with A do
  with B do 
As long as you are within the 'with B do' (in either the short or the long form), the B scope is the innermost. The search for the definition of a symbol always starts in the scope where there reference is made, and the first definition in the outwards search applies. This is always true; it is not particular to nested "with" statements.

If you, in the first example, need to reference P's C from the body of Q, you must rename Q's C. (Pascal has no syntax for explicitly referencing a local variable at an outer procedure level.) If you need to reference A's C from within a 'with B do', then you do have a syntax for it: A.C references A's C (surprise!). "with B do C:= 1" references B's C (surprise!).

This is not any problem, no sort of ambiguity, but plain scoping rules. An inner scope redefines an identically named symbol in an outer scope. If you grew up in a K&R C environment, maybe you don't have statically nested scopes under your skin. A Pascal programmer has.
Religious freedom is the freedom to say that two plus two make five.

GeneralRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
Ralf Quint20-May-24 16:48
Ralf Quint20-May-24 16:48 
GeneralRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
trønderen21-May-24 4:12
trønderen21-May-24 4:12 
GeneralRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
Ralf Quint21-May-24 6:18
Ralf Quint21-May-24 6:18 
GeneralRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
trønderen21-May-24 6:51
trønderen21-May-24 6:51 
GeneralRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
Peter Turtle19-May-24 21:47
professionalPeter Turtle19-May-24 21:47 
GeneralRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
0x01AA20-May-24 0:25
mve0x01AA20-May-24 0:25 
GeneralRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
Peter Turtle20-May-24 2:25
professionalPeter Turtle20-May-24 2:25 
GeneralRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
Al Gonzalez20-May-24 6:46
Al Gonzalez20-May-24 6:46 
GeneralRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
0x01AA20-May-24 7:06
mve0x01AA20-May-24 7:06 
GeneralRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
Ralf Quint20-May-24 8:41
Ralf Quint20-May-24 8:41 
GeneralRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
Ravi Bhavnani20-May-24 14:53
professionalRavi Bhavnani20-May-24 14:53 
GeneralRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
0x01AA21-May-24 8:26
mve0x01AA21-May-24 8:26 
GeneralRe: Fluent Api in Pascal, nothing earth-shattering ... Pin
jschell21-May-24 12:44
jschell21-May-24 12:44 
GeneralWordle 1,065 Pin
StarNamer@work18-May-24 13:32
professionalStarNamer@work18-May-24 13:32 
GeneralRe: Wordle 1,065 Pin
Sandeep Mewara18-May-24 17:09
mveSandeep Mewara18-May-24 17:09 
GeneralRe: Wordle 1,065 Pin
OriginalGriff18-May-24 20:01
mveOriginalGriff18-May-24 20:01 
GeneralRe: Wordle 1,065 Pin
Amarnath S18-May-24 20:10
professionalAmarnath S18-May-24 20:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.