[Done] Remove the confusion with "Extends"

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: [Done] Remove the confusion with "Extends"

Post by mk-soft »

Now you have taken a completely wrong turn.
In my opinion the Purebasic help is clear, how it is handled with "Extends".
The optional Extends parameter allows to extends another structure with new fields. All fields found in the extended structure will be available in the new structure and will be placed before the new fields. This is useful to do basic inheritance of structures.
Even the translation with DeepL into German is clear.
Der optionale Extends-Parameter erlaubt es, eine andere Struktur um neue Felder zu erweitern. Alle Felder, die in der erweiterten Struktur gefunden werden, sind in der neuen Struktur verfügbar und werden vor den neuen Feldern platziert. Dies ist nützlich, um grundlegende Vererbung von Strukturen durchzuführen.
The new structure is extended with the fields of the structure given with Expends. And these will be added at the beginning of the new structure. The given extended structure will not be changed.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 538
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

Re: [Done] Remove the confusion with "Extends"

Post by Sicro »

@mk-soft:
Thanks, but to make it clear: I know how the keyword Extends works.

I have nothing against the explanations in the PB help. Of course, a programmer should have a look into the PB help if the function of a command is unclear, but the first thing you see is the command name in the code and this command name should be understandable enough on its own at best.

The ambiguity of the keyword just came to my mind while I was working on my codes that use the keyword Extends in some structures and I wanted to mention the ambiguity of the keyword here in case someone had the same thought once. I was simply interested in what others thought about it.

Everybody thinks the keyword is good, I am satisfied with it and everything is ok. As you can see the topic is already marked as done since several hours.
Image
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Zach
Addict
Addict
Posts: 1654
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: [Done] Remove the confusion with "Extends"

Post by Zach »

Just wanted to comment since I saw this frame of reference brought up.
As a native english speaker, I have never found the Extends keyword to be vague in any way.


The "it could also be read to work this way" example has never so much as crossed my mind. Maybe its just a difference in grammar rules that is causing the confusion.
Image
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 538
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

Re: [Done] Remove the confusion with "Extends"

Post by Sicro »

@Zach:
Thanks.

The thought came to my mind after I saw a code that looked something like this:

Code: Select all

abstract class Class1 {...}

class Class2 extends Class1
{
  private Class1 value1 ;
  private Class1 value2 ;

  public Class2 (Class1 value1, Class1 value2) {
    this.value1 = value1 ;
    this.value2 = value2 ;
  }
}

class Class3 extends Class1
{
  private Class1 value1 ;
  private Class1 value2 ;

  public Class3 (Class1 value1, Class1 value2) {
    this.value1 = value1 ;
    this.value2 = value2 ;
  }
}
A class is of course something different than a structure, but as I interpret the code it can also be used to structure data.

But here in the thread some good points were already mentioned, which exclude a wrong interpretation of the keyword Extends as long as you remember these points (e.g. PureBasic is a single-pass compiler).
Image
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Post Reply