Lazarus

Programming => General => Topic started by: guest65109 on January 08, 2020, 01:32:41 pm

Title: [CLOSED] What is the Pascal convention?
Post by: guest65109 on January 08, 2020, 01:32:41 pm
Why Class name must be prepend with T? I saw people prepend F, P, I... before variable names. I also found people do not use Button1 as name but rename it to btnClick or something like that. What is the convention used there?
Title: Re: What is the Pascal convention?
Post by: MarkMLl on January 08, 2020, 01:37:43 pm
The important thing is to appreciate that it is a convention, rather than a hard and fast stricture of the language. In part, it's a derivative of "Hungarian Notation" which would be overkill on account of Pascal's reliable type checking.

T represents a type. F is a field in a class. P is a pointer to a type. I is an interface.

I can certainly think of at least one language where capitalisation is more than just a convention, but as others have pointed out Pascal is case-insensitive: certainly as far as the ASCII range of characters is concerned.

MarkMLl
Title: Re: What is the Pascal convention?
Post by: rvk on January 08, 2020, 01:58:18 pm
Why Class name must be prepend with T? I saw people prepend F, P, I... before variable names. I also found people do not use Button1 as name but rename it to btnClick or something like that. What is the convention used there?
The convention used is from the "Object Pascal Style Guide" (or "CodeGear Coding Style Guide lines").
https://edn.embarcadero.com/article/10280

Quote
Since one style is easier to read, Lazarus follows the CodeGear Coding Style Guide lines. Of course, almost anyone will find some points there, that are arguably less readable than other styles. That's OK, just try to follow at least 90%. See the LCL for examples.
https://wiki.freepascal.org/DesignGuidelines

The btn prefix for Button1 is also used in some C# coding conventions.
https://www.c-sharpcorner.com/UploadFile/8a67c0/C-Sharp-coding-standards-and-naming-conventions/
So they should look familar.
Title: Re: What is the Pascal convention?
Post by: Thaddy on January 08, 2020, 04:04:55 pm
Note the compiler itself has a completely different coding style... Also by convention...
Title: Re: What is the Pascal convention?
Post by: howardpc on January 08, 2020, 05:02:20 pm
I think it is more accurate to say that the compiler source exhibits various coding styles (plural). Unless by "style" you mean something considerably broader than what the term is generally understood to mean.
You can't force volunteers to write according to a particular narrow style definition. You have the sanction of rejecting contributions. But that is short-sighted if the quality of the code is very high and it is designed to be easy to maintain, but fails to adhere to a preferred style convention.
In a commercial environment, of course, the project leader has other levers s/he can apply to get employees to conform.
At some levels coding is an art as much as it is a science or a mechanical application of technique.
Title: Re: What is the Pascal convention?
Post by: marcov on January 08, 2020, 05:28:22 pm
Why Class name must be prepend with T? I saw people prepend F, P, I... before variable names. I also found people do not use Button1 as name but rename it to btnClick or something like that. What is the convention used there?

Borland Style Convention. Just the convention that Borland used for Delphi sources, adopted by most people.

Note that there are some underlying reasons for some things, like having an unified identifier namespace rather than separate normal,type and macro(const) namespaces like plain old C had, and that some of its derivatives also observe.

Similarly the F field convention is to leave the identifier without f free for the property
Title: Re: What is the Pascal convention?
Post by: valdir.marcos on January 09, 2020, 04:35:57 am
Note the compiler itself has a completely different coding style... Also by convention...
https://wiki.freepascal.org/Coding_style
Title: Re: What is the Pascal convention?
Post by: mangakissa on January 09, 2020, 08:37:39 am
Quote
Spaces

Don't use spaces around operators, colons, parentheses etc.

{ correct }
p:=p+i;

{ incorrect }
p := p + i ;
I really don't like it if all code is written without spaces. It reads terrible.
Title: Re: What is the Pascal convention?
Post by: PascalDragon on January 09, 2020, 09:20:22 am
I think it is more accurate to say that the compiler source exhibits various coding styles (plural). Unless by "style" you mean something considerably broader than what the term is generally understood to mean.
You can't force volunteers to write according to a particular narrow style definition. You have the sanction of rejecting contributions. But that is short-sighted if the quality of the code is very high and it is designed to be easy to maintain, but fails to adhere to a preferred style convention.
In a commercial environment, of course, the project leader has other levers s/he can apply to get employees to conform.
At some levels coding is an art as much as it is a science or a mechanical application of technique.

That there are multiple styles right now in the compiler's sources is for historic reasons. We have a style in the compiler that we're gearing towards and we do reject contributions that do not adhere to this (especially if they are bigger contributions, single line patches are a different topic).  The link provided by valdir.marcos lists some part of the style, though it is a work in progress to document it.

Quote
Spaces

Don't use spaces around operators, colons, parentheses etc.

{ correct }
p:=p+i;

{ incorrect }
p := p + i ;
I really don't like it if all code is written without spaces. It reads terrible.

It does not matter what you like or not (I personally don't like that the begin is on a separate line for example), but when you're working on a shared project (no matter if Open Source or in a company) you adhere to the guide lines of that project. When in Rome, do as the Romans do...
Title: Re: What is the Pascal convention?
Post by: guest65109 on January 10, 2020, 05:23:19 pm
It does not matter what you like or not (I personally don't like that the begin is on a separate line for example), but when you're working on a shared project (no matter if Open Source or in a company) you adhere to the guide lines of that project. When in Rome, do as the Romans do...

Does the Pascal world have source formatting tools like AStyle? Just fire it up and done, everything is beautiful and sane again. These tools are very sophisticated and reliable now so don't fear they will messed your source up  ::)
Title: Re: What is the Pascal convention?
Post by: MarkMLl on January 10, 2020, 05:31:49 pm
Yes, and just like C nobody agrees how things should be laid out. In other words it's down to the project managers, and you don't argue with it.

MarkMLl
Title: Re: What is the Pascal convention?
Post by: guest65109 on January 10, 2020, 05:34:43 pm
The thing I hate most is prepending a T before any class name. Why? We already know it's a Type. In many languages, Types are equivalent with Classes. It doesn't make any sense at all. The same for prepending a P before pointer name. I have seen many examples of how stupid and ridiculous it is. The most obvious example: double pointer (PP). By following this brain dead convention, you have to do a lot of typedefs. These typedefs are useless. You accuse C of using so many typedefs, but you don't see you are, too.

For example, we have a record Foo.

Pointer to Foo: type PFoo = ^Foo;

Pointer to pointer to Foo: type PPFoo = ^PFoo;

How many `P` will you prepend to it if you have to make a pointer to a pointer to a pointer to Foo?
Title: Re: What is the Pascal convention?
Post by: MarkMLl on January 10, 2020, 05:45:45 pm
Well don't do it then. You don't have to do it, as several people have explained to you it's a convention rather than a hard-and-fast syntactic rule.

But if you don't do it you're making life more difficult for people from whom you ask help. And if you don't stick to project conventions you're making extra work for whoever processes your contributions.

MarkMLl
Title: Re: What is the Pascal convention?
Post by: guest65109 on January 10, 2020, 05:46:24 pm
Yes, and just like C nobody agrees how things should be laid out. In other words it's down to the project managers, and you don't argue with it.

MarkMLl

Yes. I know. Bad practices build up over time and it's very hard to change. I can't get up early for more than ten years despite how hard I tried  :'(
Title: Re: What is the Pascal convention?
Post by: soerensen3 on January 10, 2020, 05:50:10 pm
I rarely use pointers, let alone double pointers. There might be use cases for double pointers but I cannot even imagine one.
Title: Re: What is the Pascal convention?
Post by: guest65109 on January 10, 2020, 05:50:56 pm
Well don't do it then. You don't have to do it, as several people have explained to you it's a convention rather than a hard-and-fast syntactic rule.

But if you don't do it you're making life more difficult for people from whom you ask help. And if you don't stick to project conventions you're making extra work for whoever processes your contributions.

MarkMLl

I'm on my own so I'm free to choose whatever I like. The fact is I'm from a Java foundation I like to do the Java style. Everything is plain English, class Foo is Foo but no TFoo or something like that, very easy to read and intuitive to understand. But I feared I have to follow your convention, because I need to post snippets on this forum when asking for help  ;)
Title: Re: What is the Pascal convention?
Post by: guest65109 on January 10, 2020, 05:52:51 pm
I rarely use pointers, let alone double pointers. There might be use cases for double pointers but I cannot even imagine one.

For low level API converted from C without an OOP wrapper. These double pointers are very popular and sometime we have no choice but having to use these libraries  8)
Title: Re: What is the Pascal convention?
Post by: rvk on January 10, 2020, 06:02:50 pm
I'm on my own so I'm free to choose whatever I like. The fact is I'm from a Java foundation I like to do the Java style. Everything is plain English, class Foo is Foo but no TFoo or something like that, very easy to read and intuitive to understand. But I feared I have to follow your convention, because I need to post snippets on this forum when asking for help  ;)
Ok, you can do it your own way.

Create a type Foo = class.
Now how are you going to name the instance of Foo (which is different from the class-definition) ????

In the mentioned convention it would be
type
  TFoo = class;
var
  Foo: TFoo;

Not to mention when you are declaring and instantiating the class
Convention:
  Foo := TFoo.Create;

It's clear here that TFoo is the class and Foo is the instance (variable).
When using
  myFoo := Foo.Create;
It is not clear that Foo is a class (it could as easily be a variable).
That's why there is a T before the class-names in this convention.

But if you work alone... (and nobody sees your code) it's entirely up to you.
Title: Re: What is the Pascal convention?
Post by: devEric69 on January 10, 2020, 06:13:00 pm
Quote
Why Class name must be prepend with T?

Because it's also a type, and the most important of all: so capital T at minimum (lowercase T would be incongruous) ^^.

Quote
I also found people do not use Button1 as name but rename it to btnClick or something like that. What is the convention used there?

As it has already been said, this is what is called the "Hungarian" notation.
See http://www.sourceformat.com/coding-standard-delphi-econos.htm for the component's name.
And see http://web.archive.org/web/20170124021121/http://delphi.about.com/od/standards/l/bldnc.htm for the variable's names.

A trick I took from a site, is to declare the names of oFoo objects when they were created to be destroyed in the same "scope" (within a function).
And to declare them o_Foo when it's not in the scope where they are to be destroyed.

ex..:
- Fo_Foo, or frm_This: field that stores a pointer created in the remote, and it's in the remote that created it, that it should be destroyed.
- oFoo or frmThis as var, in a procedure that creates it, and must then destroy it.
- and goFoo for global variables (like those created in intialization, and detroyed in finalization.
I also use this for parameter's name declarations.

Quote
Yes. I know. Bad practices build up over time and it's very hard to change. I can't get up early for more than ten years despite how hard I tried.

From an information theory point of view, I agree with you: the conventions of the disappeared Borland are from another age, amho.
Title: Re: What is the Pascal convention?
Post by: marcov on January 10, 2020, 07:46:38 pm
I'm on my own so I'm free to choose whatever I like. The fact is I'm from a Java foundation I like to do the Java style. Everything is plain English, class Foo is Foo but no TFoo or something like that, very easy to read and intuitive to understand. But I feared I have to follow your convention, because I need to post snippets on this forum when asking for help  ;)

So how do you call the instantiation of class Foo?  AFoo? Or do you call the type FooClass ?

Title: Re: What is the Pascal convention?
Post by: ASerge on January 10, 2020, 08:14:35 pm
Quote
Spaces

Don't use spaces around operators, colons, parentheses etc.

{ correct }
p:=p+i;

{ incorrect }
p := p + i ;
I really don't like it if all code is written without spaces. It reads terrible.
Don't forget that this is for FPC developers. For Lazarus, just the opposite is accepted (https://wiki.freepascal.org/DesignGuidelines (https://wiki.freepascal.org/DesignGuidelines)).
Title: Re: What is the Pascal convention?
Post by: lainz on January 11, 2020, 12:05:02 am
I'm on my own so I'm free to choose whatever I like. The fact is I'm from a Java foundation I like to do the Java style. Everything is plain English, class Foo is Foo but no TFoo or something like that, very easy to read and intuitive to understand. But I feared I have to follow your convention, because I need to post snippets on this forum when asking for help  ;)

So how do you call the instantiation of class Foo?  AFoo? Or do you call the type FooClass ?

Remember than in Java a class named Foo can be instantiated into foo, because the case matters. Here is not possible (but it saves some headaches when writing without care... sometimes I type FOo by mistake).
Title: Re: What is the Pascal convention?
Post by: marcov on January 11, 2020, 12:05:56 am
I'm on my own so I'm free to choose whatever I like. The fact is I'm from a Java foundation I like to do the Java style. Everything is plain English, class Foo is Foo but no TFoo or something like that, very easy to read and intuitive to understand. But I feared I have to follow your convention, because I need to post snippets on this forum when asking for help  ;)

So how do you call the instantiation of class Foo?  AFoo? Or do you call the type FooClass ?

Remember than in Java a class named Foo can be instantiated into foo, because the case matters. Here is not possible (but it saves some headaches when writing without care... sometimes I type FOo by mistake).

The point is that all that, even the casing is also just a convention.
Title: Re: What is the Pascal convention?
Post by: lainz on January 11, 2020, 12:23:55 am
The point is that all that, even the casing is also just a convention.

I'm not sure if everything human is a convention, at least the languages are conventions, the ones we speak and write.
Title: Re: What is the Pascal convention?
Post by: marcov on January 11, 2020, 12:45:14 am
The point is that all that, even the casing is also just a convention.

I'm not sure if everything human is a convention, at least the languages are conventions, the ones we speak and write.

But the human semantics and syntax aren't fixed as a compilers. But the identifier naming isn't.
Title: Re: What is the Pascal convention?
Post by: lainz on January 11, 2020, 01:12:34 am
We need Jarvis (iron man assistant) to talk with it and write code that's like a real language. Not fixed. I'm dreaming I know.
Title: Re: What is the Pascal convention?
Post by: 440bx on January 11, 2020, 02:34:31 am
I feared I have to follow your convention, because I need to post snippets on this forum when asking for help  ;)
Fear is not a good reason to follow the T prefix convention for types.  It's a convention but, there is a reason it exists (a good one too!.)  The reason is that it is _often_ useful and important to _know_ you are dealing with a type and not something else. 

Consider this code:
Code: Pascal  [Select][+][-]
  1. var
  2.   a : set of char;
  3.   i : integer;
  4.   x : char;
  5.  
  6. type
  7.   b         : 1..10;   // apparently in FPC ":" can be used instead of "=" in type declarations ???
  8.   c         = 1..10;
  9.  
  10.   TSOME_RANGE  : 1..10;
  11.   Direction : (north, east, south, west);   // accepts ":" instead of "="  ???
  12.  
  13.   TDIRECTION_ENUM1 = (north, east, south, west);      // "=" as expected
  14.  
  15.   // these are not in accordance with standard Pascal type declarations
  16.  
  17.   TDIRECTION_ENUM1 : (north, east, south, west);      // :   ???
  18.   TDIRECTION_ENUM1 =  : (north, east, south, west);   // = : ???
  19.  
  20.  
  21. var
  22.   d : Direction;
  23.   e : TDIRECTION;
  24.  
  25. begin
  26.   for x in a do ;
  27.   for i in b do ;
  28.   for i in c do ;
  29.  
  30.   for i in TSOME_RANGE do ;
  31.  
  32.   for d in Direction do ;
  33.   for e in TDIRECTION_ENUM1 do ;
  34.  
Look at the lines that start with for <varname> in <something> do ;

The problem is the <something>.  In those statements it is difficult to ascertain at a glance what the extent of the "for" is.  This is because a, b and c could be one of an enumeration, a set or a range. 

It's much nicer and clearer when not only the type is prefixed with a T but also when it is postfixed with something along the lines of "RANGE", "SET", "ENUM" because it's much easier to have at least some idea of what the statement is doing.

Aside from the examples above.  Consider you have a "Database" type.  Most programmers would like to have a variable named "Database" to refer to the type "Database" but, because the name of the variable has to be different than the name of the type and, because Pascal is not case sensitive, it makes sense to have some way to identify the type.  A very common convention used by Pascal programmers is to prefix the type with T for that reason.  That way you can have a "var Database : TDATABASE;" which is logical and sensible.  In C that is not necessary only because the language is case sensitive and just using different case for the variable name is enough to distinguish it from an, otherwise, identically named datatype.

Talking about conventions, one I wish Pascal programmers would follow is to _always_ put () after function names that require no parameters.  When you see a statement like this:
Code: Pascal  [Select][+][-]
  1. a := b;
b could be some global variable located somewhere or a function, also located "somewhere".  Now to figure out what that statement does, the programmer has to dig out from who knows where what b is.  People who are obsessed with typing less will name the function with a single letter or few letters, this usually causes a simple text search for it to return a large number of invalid hits the programmer has to wade through.  Too bad the obsession with typing less cannot be converted into obsessing about making the program easy to understand (of all obsessions, that one might be a good one.)

You shouldn't complain about Pascal being wordy.  For functions that take no parameters and for simple logical expressions, Pascal saves you from typing two characters (the parentheses that C requires but Pascal doesn't.)

Now, on a completely different note.  The lines that contain ??? deviate from the expected way types are declared in Pascal.  I don't know if that is intended in FPC but, the reference manual does not show that ":" (by itself) and "= :"as acceptable in a type definition.

HTH.
Title: Re: What is the Pascal convention?
Post by: bee on January 11, 2020, 03:25:18 am
This is a useless discussion to begin with. Convention is not law. It's just common agreements of some people upon something. It's not about right or wrong. It's about you agree or follow it, or not, which is not mandatory to anyone. That's all. Everyone could say any conventions don't make any senses for whatever reasons, and vice versa. For example, case sensitive languages (like Java) don't make any senses. How could 'foo' is different from 'Foo'? It's weird.

AFAIK, anyone who disagree with Pascal convention is mostly not a longtime Pascal programmer so s/he doesn't understand or unable to understand the reasons behind the convention. My advice is… study Pascal with Pascal mindset and paradigm. Don't ever judge Pascal convention using Java mindset and paradigm, or any other languages for that matter. Every language has its own philosophy. Deal with it.
Title: Re: What is the Pascal convention?
Post by: Handoko on January 11, 2020, 06:24:48 am
My advice is… study Pascal with Pascal mindset and paradigm. Don't ever judge Pascal convention using Java mindset and paradigm, or any other languages for that matter. Every language has its own philosophy. Deal with it.

+1
Title: Re: What is the Pascal convention?
Post by: PascalDragon on January 11, 2020, 11:10:01 am
The thing I hate most is prepending a T before any class name. Why? We already know it's a Type. In many languages, Types are equivalent with Classes. It doesn't make any sense at all. The same for prepending a P before pointer name. I have seen many examples of how stupid and ridiculous it is. The most obvious example: double pointer (PP). By following this brain dead convention, you have to do a lot of typedefs. These typedefs are useless. You accuse C of using so many typedefs, but you don't see you are, too.

For example, we have a record Foo.

Pointer to Foo: type PFoo = ^Foo;

Pointer to pointer to Foo: type PPFoo = ^PFoo;

How many `P` will you prepend to it if you have to make a pointer to a pointer to a pointer to Foo?

As 440bx wrote above, it's convenient. If I have a variable declaration x: PFoo; I don't need to guess what type x might be, instead I know it's a pointer and thus I can allocate it using New and free it using Dispose and work with it using the + operator and the […] accessor. Similar for e.g. classes, parameters, fields: I know right away what is a type, what is a parameter and what is a field. Code can get complex. And if I can spot such things without even needing the IDE to help me, that greatly simplifies things.

I rarely use pointers, let alone double pointers. There might be use cases for double pointers but I cannot even imagine one.

Double pointers are mainly relevant when dealing with C code. E.g. if you pass in memory for an "array" of pointers:
Code: C  [Select][+][-]
  1. void dumparray(int** arr, int count);
In Pascal there are two possible translations (assuming that dumparray does not modify arr):
Code: Pascal  [Select][+][-]
  1. // 1
  2. procedure dumparray(arr: PPCInt; count: CInt); cdecl; external;
  3. // 2
  4. procedure dumparray(constref arr: PCInt; count: CInt); cdecl; external;
The first declaration is closer to the original C declaration, the second can be considered more convenient.
Title: Re: What is the Pascal convention?
Post by: guest65109 on January 11, 2020, 11:32:28 am
I'm on my own so I'm free to choose whatever I like. The fact is I'm from a Java foundation I like to do the Java style. Everything is plain English, class Foo is Foo but no TFoo or something like that, very easy to read and intuitive to understand. But I feared I have to follow your convention, because I need to post snippets on this forum when asking for help  ;)

So how do you call the instantiation of class Foo?  AFoo? Or do you call the type FooClass ?

Imagine we have a class Person. We will create Person1, Person2,... but why do we have to create something whose name counter intuitive like AFoo or FooClass after all?

I also don't know why you can't let variable name just be the variable's name but prepending an `A` before it?

Take this example:

Code: Pascal  [Select][+][-]
  1. procedure TFPWebModule1.DataModuleRequest(Sender: TObject; ARequest: TRequest;
  2. AResponse: TResponse; var Handled: Boolean);
  3. begin
  4.   AResponse.Content := 'Hello, World!';
  5.   Handled := true;
  6. end;

Why it has to be ARequest but not simply Request, request or simply req? What is the meaning of this `A` after all? ARequest = A request? or ARequest = Abstract request?

All the these prefixes were intended to improve the cleanliness of the code but indeed only cause it to be more obscure and difficult to read because they are all very counter intuitive.
Title: Re: What is the Pascal convention?
Post by: guest65109 on January 11, 2020, 11:45:17 am
I'm on my own so I'm free to choose whatever I like. The fact is I'm from a Java foundation I like to do the Java style. Everything is plain English, class Foo is Foo but no TFoo or something like that, very easy to read and intuitive to understand. But I feared I have to follow your convention, because I need to post snippets on this forum when asking for help  ;)

So how do you call the instantiation of class Foo?  AFoo? Or do you call the type FooClass ?

Remember than in Java a class named Foo can be instantiated into foo, because the case matters. Here is not possible (but it saves some headaches when writing without care... sometimes I type FOo by mistake).

It's plain ridiculous! For example: we have the class Person. We would call Person1, Person2,... but never person. Even though the language is case sensitive, it's not recommended to do something like that.

p/s: with the Foo class, it should be myFoo, not AFoo.
Title: Re: What is the Pascal convention?
Post by: guest65109 on January 11, 2020, 11:53:06 am
I feared I have to follow your convention, because I need to post snippets on this forum when asking for help  ;)
Fear is not a good reason to follow the T prefix convention for types.  It's a convention but, there is a reason it exists (a good one too!.)  The reason is that it is _often_ useful and important to _know_ you are dealing with a type and not something else. 

Consider this code:
Code: Pascal  [Select][+][-]
  1. var
  2.   a : set of char;
  3.   i : integer;
  4.   x : char;
  5.  
  6. type
  7.   b         : 1..10;   // apparently in FPC ":" can be used instead of "=" in type declarations ???
  8.   c         = 1..10;
  9.  
  10.   TSOME_RANGE  : 1..10;
  11.   Direction : (north, east, south, west);   // accepts ":" instead of "="  ???
  12.  
  13.   TDIRECTION_ENUM1 = (north, east, south, west);      // "=" as expected
  14.  
  15.   // these are not in accordance with standard Pascal type declarations
  16.  
  17.   TDIRECTION_ENUM1 : (north, east, south, west);      // :   ???
  18.   TDIRECTION_ENUM1 =  : (north, east, south, west);   // = : ???
  19.  
  20.  
  21. var
  22.   d : Direction;
  23.   e : TDIRECTION;
  24.  
  25. begin
  26.   for x in a do ;
  27.   for i in b do ;
  28.   for i in c do ;
  29.  
  30.   for i in TSOME_RANGE do ;
  31.  
  32.   for d in Direction do ;
  33.   for e in TDIRECTION_ENUM1 do ;
  34.  
Look at the lines that start with for <varname> in <something> do ;

The problem is the <something>.  In those statements it is difficult to ascertain at a glance what the extent of the "for" is.  This is because a, b and c could be one of an enumeration, a set or a range. 

It's much nicer and clearer when not only the type is prefixed with a T but also when it is postfixed with something along the lines of "RANGE", "SET", "ENUM" because it's much easier to have at least some idea of what the statement is doing.

Aside from the examples above.  Consider you have a "Database" type.  Most programmers would like to have a variable named "Database" to refer to the type "Database" but, because the name of the variable has to be different than the name of the type and, because Pascal is not case sensitive, it makes sense to have some way to identify the type.  A very common convention used by Pascal programmers is to prefix the type with T for that reason.  That way you can have a "var Database : TDATABASE;" which is logical and sensible.  In C that is not necessary only because the language is case sensitive and just using different case for the variable name is enough to distinguish it from an, otherwise, identically named datatype.

Talking about conventions, one I wish Pascal programmers would follow is to _always_ put () after function names that require no parameters.  When you see a statement like this:
Code: Pascal  [Select][+][-]
  1. a := b;
b could be some global variable located somewhere or a function, also located "somewhere".  Now to figure out what that statement does, the programmer has to dig out from who knows where what b is.  People who are obsessed with typing less will name the function with a single letter or few letters, this usually causes a simple text search for it to return a large number of invalid hits the programmer has to wade through.  Too bad the obsession with typing less cannot be converted into obsessing about making the program easy to understand (of all obsessions, that one might be a good one.)

You shouldn't complain about Pascal being wordy.  For functions that take no parameters and for simple logical expressions, Pascal saves you from typing two characters (the parentheses that C requires but Pascal doesn't.)

Now, on a completely different note.  The lines that contain ??? deviate from the expected way types are declared in Pascal.  I don't know if that is intended in FPC but, the reference manual does not show that ":" (by itself) and "= :"as acceptable in a type definition.

HTH.

This is a useless discussion to begin with. Convention is not law. It's just common agreements of some people upon something. It's not about right or wrong. It's about you agree or follow it, or not, which is not mandatory to anyone. That's all. Everyone could say any conventions don't make any senses for whatever reasons, and vice versa. For example, case sensitive languages (like Java) don't make any senses. How could 'foo' is different from 'Foo'? It's weird.

AFAIK, anyone who disagree with Pascal convention is mostly not a longtime Pascal programmer so s/he doesn't understand or unable to understand the reasons behind the convention. My advice is… study Pascal with Pascal mindset and paradigm. Don't ever judge Pascal convention using Java mindset and paradigm, or any other languages for that matter. Every language has its own philosophy. Deal with it.

Long story short this naming convention is indeed a workaround for the limitations of this language. If I want to use this language, I have to follow this discipline. If I don't want to follow this discipline, I simply shouldn't use the language at all. The same thing also true for C. This thread should be closed.
Title: Re: What is the Pascal convention?
Post by: rvk on January 11, 2020, 11:53:56 am
We would call Person1, Person2,... but never person.
Hahahahaha  :D Isn't that a convention too. Adding 1, 2 or 3 after a variable name?
Why would that be any different from prefixing T before the class?

Prefixing and adding a letter to variable and classes do make your code more readable and (what's more important) easier to maintain and bugfix.

I think you need to get some programming experience with bigger programs (and preferably more programmers). You'll find out conventions are there for a reason.

But again, if you are on your own and you don't share code, you can do whatever you want.
Title: Re: What is the Pascal convention?
Post by: marcov on January 11, 2020, 12:00:10 pm
Why it has to be ARequest but not simply Request, request or simply req? What is the meaning of this `A` after all? ARequest = A request? or ARequest = Abstract request?

Well, that is the point.  If instance and class have the same default name, you get a lot of clashes, or the unnatural situation with multiple namespaces (or other hacks) to mask that the same name can mean multiple things.

But again, if you are on your own and you don't share code, you can do whatever you want.

Like Martin of MSEGUI fame, who suffixed -ty :-)
Title: Re: What is the Pascal convention?
Post by: guest65109 on January 11, 2020, 12:05:13 pm
We would call Person1, Person2,... but never person.
Hahahahaha  :D Isn't that a convention too.

I do not against convention but stupid and counter intuitive convention, man.

p/s: about Person1, Person2,... it's just natural way of doing thing, no convention needed.
Title: Re: What is the Pascal convention?
Post by: guest65109 on January 11, 2020, 12:07:50 pm
Why it has to be ARequest but not simply Request, request or simply req? What is the meaning of this `A` after all? ARequest = A request? or ARequest = Abstract request?

Well, that is the point.  If instance and class have the same default name, you get a lot of clashes, or the unnatural situation with multiple namespaces (or other hacks) to mask that the same name can mean multiple things.

But again, if you are on your own and you don't share code, you can do whatever you want.

Like Martin of MSEGUI fame, who suffixed -ty :-)

What exactly the `A` mean? `A` or `Abstract` or... `Arbitrary`?
Title: Re: What is the Pascal convention?
Post by: marcov on January 11, 2020, 12:13:09 pm
What exactly the `A` mean? `A` or `Abstract` or... `Arbitrary`?

It is the natural language article (https://en.wikipedia.org/wiki/Article_(grammar)) as in "a man" or "a house".  So not to different from suffixing 1. Just using words instead of numerals. (and shorter and with a bit less emphasis than the direct equivalent of "1", "one")

So strictly speaking it should be AnIdentifier, not AIdentifier :-) But the capitalization already makes the distinction, and natural language was of course never designed to be written anyway. Its origins are speech.

I do not against convention but stupid and counter intuitive convention, man.

Personally I get the feeling you never got the convention, no more, Pascal as a whole much chance. If you are determined to find fault with something, it is easy.
Title: Re: [CLOSED] What is the Pascal convention?
Post by: BrunoK on January 11, 2020, 04:04:12 pm
Code: Pascal  [Select][+][-]
  1. procedure TFPWebModule1.DataModuleRequest(Sender: TObject; ARequest: TRequest;
  2. AResponse: TResponse; var Handled: Boolean);
  3. begin
  4.   AResponse.Content := 'Hello, World!';
  5.   Handled := true;
  6. end;

Why it has to be ARequest but not simply Request, request or simply req? What is the meaning of this `A` after all? ARequest = A request? or ARequest = Abstract request?
The leading A in ARequest and AResponse convey, when referenced in the body of the implemented procedure/function, that we are  dealing with a passed parameter, not a procedure var or protected fields. If dealing with more than 10 lines in a procedure, this hint is very useful.

Sadly, this convention is not applied everywhere thus you find declaration like :
Code: Pascal  [Select][+][-]
  1. function TWin32WidgetSet.EnableWindow(HWnd: HWND; BEnable: Boolean): Boolean;
This makes it difficult to differenciate, in the  EnableWindow function, if one is dealing with a parameter or a type, this did (maybe still so) confuse the debugger.

Had it been defined :
Code: Pascal  [Select][+][-]
  1. function TWin32WidgetSet.EnableWindow(aHWnd: HWND; aEnable: Boolean): Boolean;
It would be much clearer in the body of the function that aHWnd is accessing the passed parameter value.

I have a personal convention to define, for example, any record definition this way :
Code: Pascal  [Select][+][-]
  1. type
  2.   RUInt128 = record
  3.   Private
  4.     FValue : record
  5.       case boolean of
  6.       false: (CurrencyA : array[0..1] of Currency);
  7.       true: (QW64a : array[0..1] of QWord);
  8.     end;
  9.     FNeg : boolean;
  10.     function  GetValue : Currency;
  11.     procedure SetValue(aCurrency :  Currency);
  12.   public
  13.     property AsCurrency : Currency read GetCurrency write SetValue;
  14.   end;
  15.  
This gives the following informations when dealing with this type :
The leading R for the record name means, in a procedure that would declare it, that it exists on stack storage of the procedure and will disappear when the procedure exits.

FValue, FNeg (private) are 2 fields that should only be accessed/modified directly in the unit implementation. This is generally enforced in delphi / FPC / Lazarus.

A private convention is that the A / a trailing character in CurrencyA / QW64a are arrays fields, it makes things easier to figure out when they appear in the code.

These conventions, once you figure which ones are applied since they are just naming conventions, help a great deal in understanding code and long term may make the difference between maintainable code or seemingly obfuscated code that will die if buggy.

In any case, having GOOD NAMES for class / variable / field / methods / etc... is not easy and often takes time in development. If the application to write is not trivial, determining names is part of a project analysis, they may be defined by the designers before the first line of code is written.
Title: Re: [CLOSED] What is the Pascal convention?
Post by: soerensen3 on January 11, 2020, 04:26:09 pm
I don't know for sure but I think the A is for attribute. P like parameter was already taken for pointers.
I think it makes sense to prepend the A in some situations where you have a property a field and a parameter which are quite common:
Code: Pascal  [Select][+][-]
  1. type
  2.   TSomeObject = class ( TObject )
  3.     private
  4.       FParent: TSomeObject;
  5.  
  6.     public
  7.       constructor Create( AParent: TSomeObject );
  8.  
  9.     published
  10.       property Parent: TSomeObject read FParent write FParent;
  11.   end;
  12.  
  13. [...]
  14.  
  15. constructor TSomeObject.Create ( AParent: TSomeObject );
  16. begin
  17.   inherited Create;
  18.   FParent:= AParent;
  19. end;
  20.  
  21.  
So Parent is the property, FParent is the field and AParent is the parameter of a function/procedure.
Title: Re: [CLOSED] What is the Pascal convention?
Post by: howardpc on January 11, 2020, 05:23:33 pm
I don't know for sure but I think the A is for attribute.
No, as Marco writes, it is simply the indefinite article prefixed without a space since identifiers cannot contain space characters.
There is a lot to be said for sticking to universal conventions.
For most of my adult life I moved an indicator stick on the right of the steering column to signal before turning the car.
On a more recent model, with steering column sticks reversed, whenever I signal to turn, I turn the windscreen wipers on instead.  :)
Title: Re: [CLOSED] What is the Pascal convention?
Post by: soerensen3 on January 11, 2020, 07:52:55 pm
I don't know for sure but I think the A is for attribute.
No, as Marco writes, it is simply the indefinite article prefixed without a space since identifiers cannot contain space characters.

I like my version better  :P
Title: Re: [CLOSED] What is the Pascal convention?
Post by: howardpc on January 11, 2020, 08:29:44 pm
I like my version better  :P
Why not indeed?
How a particular naming convention may have arisen is unimportant.

The value of such naming systems is the support they provide in producing readable and easily maintainable code, code that is less likely to contain bugs because of ambiguity and so on.
All languages (not just Pascal) benefit from care taken over naming of variables and routines and data structures.

Self-explanatory names, and names that encode other useful at-a-glance information (this is a pointer, this is an array, this instance needs to be manually freed, this is a type not a variable, etc.) allow you to write almost self-documenting code, requiring little in the way of additional comments to be immediately comprehensible by other programmers.
In a forum such as this where code offered is going to be read by many eyes, adopting a few common coding conventions is a courtesy to others.
Title: Re: What is the Pascal convention?
Post by: Handoko on January 11, 2020, 09:45:36 pm
I have seen many examples of how stupid and ridiculous it is.

Please do not say it is stupid or ridiculous before you really understand the reasons. It's only make you seem like a troll. I don't know why you gone but came back again and again. But I'm glad to see, your language now 'better' than previously. That's a good improvement.

Actually there is no a 'perfect' language or dev tool that for everyone. What works for others may not work for you. And there is no a single one suitable for all kinds of projects.  Each tools have its own advantages and disadvantages. You do not have to pick the tool because others say it is good. And you do not have to limit yourself using only 1 tool.

Honestly I envy about you, in a positive way. You know some basic of various languages and tools, C, Java, Python, etc. And you're still young, you have a very long time for the journey to absorb lots of new things. A good programmer should be able to use various of tools. Instead of forcing yourself to 'accept' Pascal, why don't you just use them all.

Each of the things you complained, we have the reasons to counter. I read the answers, they really answered well. But I think, you're unable to fully understand and still not agree.

My suggestion is, try to develop a 'real' software instead of a hello world program. Maybe a simple game, stock control, personal todo and note book. By doing a real project, then you will see the beauty of Pascal, you will understand why readability and maintainability is important and why the conventions are needed. Experience it yourself is best way to learn.

Maybe later you will find that, Pascal is not for you. That's okay. A while ago, there was a user in the forum asking a lot of questions to find out is Lazarus/FPC suitable for him. Later he left for RemObjects Oxygene. Also a kid who was able to write a simple game using FPC after learning Pascal in weeks. He privately contacted me, telling me C++ is awesome because you type less. Great to hear he found the thing that suitable for him, I didn't try to convince him Pascal is better. We do not always pick the best but we usually choose the one we like most.

You were lucky to get lots of answers from 'real' programmers here. Most of them really built huge projects and have decades of experience.

Have a nice weekend.
Title: Re: What is the Pascal convention?
Post by: valdir.marcos on January 12, 2020, 04:04:05 am
I have seen many examples of how stupid and ridiculous it is.

Please do not say it is stupid or ridiculous before you really understand the reasons. It's only make you seem like a troll. I don't know why you gone but came back again and again. But I'm glad to see, your language now 'better' than previously. That's a good improvement.

Actually there is no a 'perfect' language or dev tool that for everyone. What works for others may not work for you. And there is no a single one suitable for all kinds of projects.  Each tools have its own advantages and disadvantages. You do not have to pick the tool because others say it is good. And you do not have to limit yourself using only 1 tool.

Honestly I envy about you, in a positive way. You know some basic of various languages and tools, C, Java, Python, etc. And you're still young, you have a very long time for the journey to absorb lots of new things. A good programmer should be able to use various of tools. Instead of forcing yourself to 'accept' Pascal, why don't you just use them all.

Each of the things you complained, we have the reasons to counter. I read the answers, they really answered well. But I think, you're unable to fully understand and still not agree.

My suggestion is, try to develop a 'real' software instead of a hello world program. Maybe a simple game, stock control, personal todo and note book. By doing a real project, then you will see the beauty of Pascal, you will understand why readability and maintainability is important and why the conventions are needed. Experience it yourself is best way to learn.

Maybe later you will find that, Pascal is not for you. That's okay. A while ago, there was a user in the forum asking a lot of questions to find out is Lazarus/FPC suitable for him. Later he left for RemObjects Oxygene. Also a kid who was able to write a simple game using FPC after learning Pascal in weeks. He privately contacted me, telling me C++ is awesome because you type less. Great to hear he found the thing that suitable for him, I didn't try to convince him Pascal is better. We do not always pick the best but we usually choose the one we like most.

You were lucky to get lots of answers from 'real' programmers here. Most of them really built huge projects and have decades of experience.

Have a nice weekend.
Nice words. Thanks.
Title: Re: What is the Pascal convention?
Post by: guest65109 on January 13, 2020, 05:04:21 pm
Please do not say it is stupid or ridiculous before you really understand the reasons. It's only make you seem like a troll. I don't know why you gone but came back again and again. But I'm glad to see, your language now 'better' than previously. That's a good improvement.

So you recognized me? I'm not a troll. At least, I'm not intended to be but somehow I behaved exactly like one. If you want to know, the reason is: I expected too much from Free Pascal and Lazarus because people here are too good at convincing. Anytime I concluded Free Pascal and Lazarus sucks, they could counter me and through their words every faults come back into myself. It's always my faults but not Free Pascal and Lazarus. I'm partially convinced and try again and again. Another factor is I want my programs, if I could make any, could be compiled and run across all of the platforms I used: windows, linux, 4 bsds, openindiana and haikuos. Only Free Pascal and Lazarus could fulfill this, apart from Java. I started from Java, but I never really love it. I found it to be complicated. Plus many bashing arguments from people there. Finally, I realized. I don't like the RAD approach at all. I'm happy with console programs. I have to admit, Object Pascal as a language is better than C and simpler than C++. I could do these console programs in any language, but I choose Pascal, because of the Lazarus IDE. It is not the best IDE but it will compile and available everywhere. For example, NetBSD. You could check on pkgsrc.se they really has many IDEs for many languages available. But the fact is, none of them really work. Some of them even not possible to build, you see the port for them but there is no binary packages to install them because the porter themselves, can't get the software to be build. The FOSS world is Linux centric, making any efforts the port software to non Linux platforms even Unix based, is a nontrivial task. With Lazarus, I have a good enough IDE for the OS I use. The fact is I use so many OSes, the same Lazarus IDE running across all of them, I would definitely prefer one IDE, one language other than a bunch of languages and different IDEs that I can't even possible to learn all of them. If you in my position, I'm sure you would choose like me. But Lazarus has problem with displaying the output of console programs on platforms other than windows. I have asked the developers so many times, a virtual terminal emulator, or vte, is the answer for everything, but they always ignore me or ask me to provide patches myself. You know, if I could provide these patches, I would happily with the gui programs development, no need for console programs, at all. I expected from Free Pascal and Lazarus so much. This is my biggest fault. This expectation, and the stress, converted into hate.
Title: Re: What is the Pascal convention?
Post by: marcov on January 13, 2020, 05:50:39 pm
My suggestion is, try to develop a 'real' software instead of a hello world program. Maybe a simple game, stock control, personal todo and note book. By doing a real project, then you will see the beauty of Pascal, you will understand why readability and maintainability is important and why the conventions are needed. Experience it yourself is best way to learn.

One learns the most from projects where one can't change the conditions/deliverables to suit a favoured (easy) solution. E.g. an administration application for some local non-profit is the ultimate test I think.
Title: Re: What is the Pascal convention?
Post by: MarkMLl on January 13, 2020, 05:58:53 pm
One learns the most from projects where one can't change the conditions/deliverables to suit a favoured (easy) solution. E.g. an administration application for some local non-profit is the ultimate test I think.

One learns even more when ones boss can- and does change things, without regard to the ease of solution.

MarkMLl
Title: Re: [CLOSED] What is the Pascal convention?
Post by: Handoko on January 13, 2020, 06:10:22 pm
@mr.coll

I knew you're not a troll. And yeah, impatient and expecting too much can sometimes cause problems.

Actually, it's not fully your fault nor Lazarus/FPC nor someone else. You're wanting some features but they haven't implemented yet.

And what you said about the console issue, we knew about it. On recent Lazarus 2.0.6 Linux, I clearly saw some improvements about the Console Output, but still it hasn't really solve the problem. I rarely write console programs. But I if do, I usually test running it directly from the Terminal not Console Output window.

The great thing about Lazarus/FPC is it has a lot of awesome features unfortunately some of them still need works to be really useful. And the biggest challenge is - I guess you already know - manpower.

Hey, you can help. You don't need to be clever enough to write the patch yourself. If you find something not working as what it should be, instead of complaining, you can provide the details. Steps to reproduce, the source code, screenshots, etc. So the developers will be able to understand and solve the issue faster.

And please be patient. Fixing bugs isn't an easy task. I'm very good fixing my own bugs but there were times I tried fix the bugs in the Bugtracker, unfortunately I can't. They were too hard for me. If you visit the Bugtracker, there you will see the developers are really working hard fixing them. But there are too many items in the list.
Title: Re: [CLOSED] What is the Pascal convention?
Post by: bee on January 14, 2020, 02:11:16 am
I write a lot of console programs, especially for Linux, because I made a lot of web services and server tools using Free Pascal. If you don't do GUI programming, I think Lazarus IDE is overkill. And its console window is still unable to handle ANSI code and unicode correctly.

My favourite editor to write console program using Free Pascal is Microsoft's VS Code with OmniPascal extension. VS Code's integrated terminal panel is awesome. Also its git built-in integration, ability to connect to remote server through ssh, etc are also very useful and better than Lazarus IDE. Using VS Code, you don't need Lazarus IDE, just pure FPC (the compiler, RTL, and FCL).

I've written a tutorial how to use Free Pascal with VS Code, but it's written in Bahasa Indonesia. You may use Google Translate to read it in you favourite language though. You may read it here (https://paklebah.github.io/fpc-dan-vscode.html). In that blog, I also wrote some other Pascal tutorials (using VS Code) as well.
Title: Re: [CLOSED] What is the Pascal convention?
Post by: guest65109 on January 14, 2020, 05:44:08 am
I'm not yet give up on Free Pascal and Lazarus. I fired up VirtualBox and setup the free trial Windows 7 IE Development image from Microsoft. You know how disappointed I am? Lazarus can't rebuild itself because of an stupid error:
Quote
Fatal: Unable to open file C:UsersIEUserAppDataLocallazarusidemake.cfg -di386
I have to use the version from getlazarus.org because it's already docked.
Title: Re: [CLOSED] What is the Pascal convention?
Post by: MarkMLl on January 14, 2020, 10:01:10 am
I write a lot of console programs, especially for Linux, because I made a lot of web services and server tools using Free Pascal. If you don't do GUI programming, I think Lazarus IDE is overkill. And its console window is still unable to handle ANSI code and unicode correctly.

I did some work on that about a year ago. From what I could see the major issue is a Pascal language one, i.e. how to accept a stream (term used loosely) of arbitrary data from gdb and emit is as either 8-bit codepoints or UTF-8 etc.

MarkMLl
Title: Re: What is the Pascal convention?
Post by: marcov on January 14, 2020, 10:41:01 am
One learns the most from projects where one can't change the conditions/deliverables to suit a favoured (easy) solution. E.g. an administration application for some local non-profit is the ultimate test I think.

One learns even more when ones boss can- and does change things, without regard to the ease of solution.

Yes. I'd generalize that to not being entirely top-down overviewable at the start. It is the first thing you learn after college. Specs are not always up front, not always logic or complete and not always set in stone.

Due to PHB or other reasons. Firsts of its kind often has intrinsic problems too, working with remote customers too.
Title: Re: [CLOSED] What is the Pascal convention?
Post by: guest65109 on January 14, 2020, 12:05:03 pm
I'm using the Free Pascal text IDE. Glad that it also works on Linux. But on systems other than Linux and Windows, it's broke. It seemed it's some issues with curses so mouse click will not work under the terminal emulator.

Frankly, no one care about the text mode IDE at all because everything now focus on the superior Lazarus IDE. I hope the text mode IDE should get more attention.
Title: Re: [CLOSED] What is the Pascal convention?
Post by: MarkMLl on January 14, 2020, 12:27:41 pm
Frankly, no one care about the text mode IDE at all because everything now focus on the superior Lazarus IDE. I hope the text mode IDE should get more attention.

Congratulations, and we all look forward to seeing your patches :-)

It's a while since I've looked at the text IDE on Solaris, but I'm pretty sure that I had it working. I agree that the mouse side is a problem, but in fairness we didn't have that sort of thing in the late Turbo Pascal era which is approximately what that IDE seeks to emulate. What other OSes are you interested in here, and do they actually have any text-mode mouse support?

Way back, MS had a Visual Basic IDE for DOS which was really not at all bad: the only downside is that you had to swap between form designer and editor modes due to memory etc. limitations. I've always felt that it was a great pity that something like that wasn't available for Linux etc. using Curses.

MarkMLl
Title: Re: [CLOSED] What is the Pascal convention?
Post by: lucamar on January 14, 2020, 03:00:22 pm
[...] in fairness we didn't have that sort of thing in the late Turbo Pascal era which is approximately what that IDE seeks to emulate.

Mouse support was introduced in Turbo Pascal's IDE in version 6.0, in 1990, with the advent of Turbo Vision. The problems in Free Pascal IDE's mouse support arise basically from its multi-platform nature and the differing way each OS has of managing the rodent; much more so when the IDE has to "mmic" TP and appear to work exactly the same in all platforms. It's not exactly an easy task and it is worsened by the lack of development, modernization and maintenance of Free Vision.

Which is really a pity: there's still place in the world for a modern, advanced TUI framework. :(
Title: Re: [CLOSED] What is the Pascal convention?
Post by: bee on January 14, 2020, 03:11:53 pm
Sometimes it's easier to just work from a remote machine, even from within the same local network. That's what I've done since I knew VS Code. I could work on my local Raspberry Pi or my remote Linux VPS from my lovely Macbook Pro using Free Pascal with VS Code through ssh. No need to work directly on the target machine. I think ssh does work on BSDs, am I right? :)
Title: Re: [CLOSED] What is the Pascal convention?
Post by: MarkMLl on January 14, 2020, 03:27:14 pm
I think ssh does work on BSDs, am I right? :)

I believe so, but mouse support (libgpm) possibly doesn't- particularly remotely.

MarkMLl
Title: Re: [CLOSED] What is the Pascal convention?
Post by: marcov on January 14, 2020, 03:40:33 pm
I'm using the Free Pascal text IDE. Glad that it also works on Linux. But on systems other than Linux and Windows, it's broke. It seemed it's some issues with curses so mouse click will not work under the terminal emulator.

Frankly, no one care about the text mode IDE at all because everything now focus on the superior Lazarus IDE. I hope the text mode IDE should get more attention.

A bit. After Lazarus matured in 2007-2008 new development for the textmode IDE petered out. But that was also a bit because the few devels doing it simply lost steam. Peter left FPC, and Pierre is still there, but doesn't work on Lazarus.

I from time to time also tried to further it (e.g. replacing the helpsystem with the CHM based system), but realized that  the textmode IDE has a hopelessly dated design ( copy of something early nineties pieced together from clones):

So basically if you really want to further it, you need to start over and bring the textmode system to Delphi technology (late nineties).

And yes, the sad state of *nix consoles (difficult to program, variable, underdocumented) doesn't help either.

The textmode IDE always has worked best with XTerm.



Title: Re: [CLOSED] What is the Pascal convention?
Post by: guest65109 on January 14, 2020, 04:32:04 pm
Sometimes it's easier to just work from a remote machine, even from within the same local network. That's what I've done since I knew VS Code. I could work on my local Raspberry Pi or my remote Linux VPS from my lovely Macbook Pro using Free Pascal with VS Code through ssh. No need to work directly on the target machine. I think ssh does work on BSDs, am I right? :)

X11 port forwarding over ssh? How could you do this with an heavy gui software like VS Code without unbearable lagging, I wonder? Do you use solution like NX or X2Go?
Title: Re: [CLOSED] What is the Pascal convention?
Post by: guest65109 on January 14, 2020, 04:33:05 pm
I think ssh does work on BSDs, am I right? :)

I believe so, but mouse support (libgpm) possibly doesn't- particularly remotely.

MarkMLl

So it's because of that sh*t library caused mouse to not work on the text mode IDE? As I know the curses part would have no problems.
Title: Re: [CLOSED] What is the Pascal convention?
Post by: guest65109 on January 14, 2020, 04:37:23 pm
I'm using the Free Pascal text IDE. Glad that it also works on Linux. But on systems other than Linux and Windows, it's broke. It seemed it's some issues with curses so mouse click will not work under the terminal emulator.

Frankly, no one care about the text mode IDE at all because everything now focus on the superior Lazarus IDE. I hope the text mode IDE should get more attention.

A bit. After Lazarus matured in 2007-2008 new development for the textmode IDE petered out. But that was also a bit because the few devels doing it simply lost steam. Peter left FPC, and Pierre is still there, but doesn't work on Lazarus.

I from time to time also tried to further it (e.g. replacing the helpsystem with the CHM based system), but realized that  the textmode IDE has a hopelessly dated design ( copy of something early nineties pieced together from clones):
  • Turbo Pascal (not Delphi) object model
  • Turbo Pascal (not Delphi) string support (255 chars max)
  • no unicode
  • TUI entirely managed in code, no designer, hard to maintain
  • Streaming also manual. No RTTI

So basically if you really want to further it, you need to start over and bring the textmode system to Delphi technology (late nineties).

And yes, the sad state of *nix consoles (difficult to program, variable, underdocumented) doesn't help either.

The textmode IDE always has worked best with XTerm.

Thanks for let us know. Then I would not waste my time with the text mode IDE. I will use Geany and invoke the fpc compiler to compile my code.
Title: Re: [CLOSED] What is the Pascal convention?
Post by: marcov on January 14, 2020, 04:59:04 pm
I think ssh does work on BSDs, am I right? :)

I believe so, but mouse support (libgpm) possibly doesn't- particularly remotely.

gpm is Linux only. BSD use moused.

Afaik the mouse worked on FreeBSD under xterm using the xterm mouse support. Maybe also on putty since that is an xtermy emulator. (though might need some settings changed)

Title: Re: [CLOSED] What is the Pascal convention?
Post by: PascalDragon on January 15, 2020, 09:08:25 am
Sometimes it's easier to just work from a remote machine, even from within the same local network. That's what I've done since I knew VS Code. I could work on my local Raspberry Pi or my remote Linux VPS from my lovely Macbook Pro using Free Pascal with VS Code through ssh. No need to work directly on the target machine. I think ssh does work on BSDs, am I right? :)

X11 port forwarding over ssh? How could you do this with an heavy gui software like VS Code without unbearable lagging, I wonder? Do you use solution like NX or X2Go?
Don't underestimate X11 forwarding. Especially if you're using it on the local network. I've used it with Firefox quite some time ago. Alternatively you could try VNC. At work we use that for browsing as well.

Though bee probably didn't mean GUI, but simply invoking the compiler through SSH.
Title: Re: [CLOSED] What is the Pascal convention?
Post by: MarkMLl on January 15, 2020, 09:19:57 am
Don't underestimate X11 forwarding. Especially if you're using it on the local network. I've used it with Firefox quite some time ago. Alternatively you could try VNC. At work we use that for browsing as well.

Though bee probably didn't mean GUI, but simply invoking the compiler through SSH.

VNC is generally more efficient, even if it means transferring an entire desktop environment. I use it heavily but remote X11 has had problems at various times with- in particular- Lazarus and Firefox, the cause was believed to be excessive polling of input devices.

Generally speaking, my first choice is X11 over SSH, my second is Xephyr, and my third is VNC.

MarkMLl
Title: Re: [CLOSED] What is the Pascal convention?
Post by: bee on January 15, 2020, 09:20:30 am
Though bee probably didn't mean GUI, but simply invoking the compiler through SSH.
Yup. Most of my Linux remote machines don't even have X installed. I meant by work remotely is simply open ssh connection to a remote machine, edit the source code via VS code through sftp, and then compile it on the remote machine through ssh terminal. I don't need mouse support nor GUI for that since my program is console or web program. :)
Title: Re: [CLOSED] What is the Pascal convention?
Post by: marcov on January 15, 2020, 11:52:29 am
Note that in general for remote X machines, you installed no X, but then manually only the parts needed for remote use and a simple manager like window maker.

I did this for quite a while when working at the university that had Hummingbird Xserver licenses in the early 2000s. I Xed home over putty's X forwarding to mostly FreeBSD machines.

Iirc it mostly worked fine, but managing Lazarus multiple windows sometimes was a chore. Starting mozilla (then just released "netscape 6") was very slow though, probably because mostly owner drawn.

Title: Re: [CLOSED] What is the Pascal convention?
Post by: guest65109 on January 15, 2020, 01:36:16 pm
Though bee probably didn't mean GUI, but simply invoking the compiler through SSH.
Yup. Most of my Linux remote machines don't even have X installed. I meant by work remotely is simply open ssh connection to a remote machine, edit the source code via VS code through sftp, and then compile it on the remote machine through ssh terminal. I don't need mouse support nor GUI for that since my program is console or web program. :)

Oh. I know this setup. You are not using X11 port forwarding from the remote machine to your local machine. The remote machine should be called a build server. I would recommend you to use NFS or Samba share over SFTP for performance reason.
Title: Re: [CLOSED] What is the Pascal convention?
Post by: lucamar on January 15, 2020, 04:01:48 pm
The remote machine should be called a build server. I would recommend you to use NFS or Samba share over SFTP for performance reason.

Since the build is done in the remote machine (which is, presumably, more powerful) the performance over ssh (just sending commands to the remote) should be greater than if the build was made in the (presumably "poorer") local machine accessing the source over "remote-disk" protocols.

It all depends, of course, on what you want to do, the relative "merits" of both machines and the communication speed of the link between them.  :)
TinyPortal © 2005-2018