Hello.
Read the documentation for new class syntax in order to make a support in
my IDEA perl support plugin. And one thing perplexed me:
> class and package declarations are similar, but classes automatically get
a constructor named new - You don't have to (and should not) write one.
This is a bit strange, because code like following is pretty usual
(java-like example):
```
class GenericAnimal {
private String myFamily;
public GenericAnimal(String family){
myFamily = family;
}
}
```
```
class GenericCat extends GenericAnimal {
public GenericCat(.... some cat related stuff...){
super("cats");
.... set up cat related stuff
}
}
```
Or
```
class FourLegsAnimal extends GenericAnimal {
public FourLegsAnimal(AnimalDescriptor animalDescriptor){
super(computeFamily(animalDescriptor));
}
private String computeDescriptor(AnimalDescriptor animalDescriptor){
// computing some stuff
}
}
```
So the point is: subclasses may want to amend/compute constructor
parameters for the super-classes.
Read the documentation for new class syntax in order to make a support in
my IDEA perl support plugin. And one thing perplexed me:
> class and package declarations are similar, but classes automatically get
a constructor named new - You don't have to (and should not) write one.
This is a bit strange, because code like following is pretty usual
(java-like example):
```
class GenericAnimal {
private String myFamily;
public GenericAnimal(String family){
myFamily = family;
}
}
```
```
class GenericCat extends GenericAnimal {
public GenericCat(.... some cat related stuff...){
super("cats");
.... set up cat related stuff
}
}
```
Or
```
class FourLegsAnimal extends GenericAnimal {
public FourLegsAnimal(AnimalDescriptor animalDescriptor){
super(computeFamily(animalDescriptor));
}
private String computeDescriptor(AnimalDescriptor animalDescriptor){
// computing some stuff
}
}
```
So the point is: subclasses may want to amend/compute constructor
parameters for the super-classes.