[Gambas-user] Suggestions 4 new keywords

Fabien Bodard gambas.fr at ...626...
Wed Sep 15 09:35:04 CEST 2010


I think for my part , there is two thing bad in your idea...
  - it is not more short than the current implementation .
  - it not respect the Procedure syntax (but can be sympatic in the
case of implementation of MACRO)
  You say it is more easy to read ... yes ... but you manage only one
case in the validation ... imagine managing mutiple validation for one
entry ... it will be less clear.



In fact my question will be what is not clear for you in the Gambas Code ...

Properties are declared separattly..

All variable are in top of class and local in top of procedure ...

then we have in gb3 an explorer that show the class content ...

To finish ... programming in not easy ... gambas is not a one thing
langage and must to be able to do near to everything (just it miss
some velocity ... it's an interpreted langage) so it need to learn a
little bit about what is aroud the langage and about généric
programmation. A C++ program is more explicit ... but users go to
Basic because of these simplification.... You can try C# or Basic.net
:)
and i'm not sure they are more simple.


Nevertheless... Gambas language will not change for this time, gb4...
in ... 3-4 year will be another thing.





2010/9/15 Fabián Flores Vadell <fabianfloresvadell at ...626...>:
> Hi Benoît. Below I expose some suggestions for new and alternative keywords.
>
> PUBLIC and PRIVATE keywords defines the scope for attributes and
> methods, but this words come from (or evokes) modular/structured
> programming. Because PUBLIC methods and attributes (and properties)
> define the interface for a class, I think that a good and alternative
> syntax could be based in new keyword like INTERFACE, IMPLEMENTATION,
> METHOD, ATTRIBUTE, PROPERTY, VALIDATE, etc.
>
> Example:
>
> PUBLIC Name AS String
> PUBLIC LastName AS String
>
> PRIVATE iAge AS Byte
>
> PROPERTY Age AS Byte
>
> PRIVATE FUNCTION Age_Read() AS Byte
>  RETURN iAge
> END
>
> PRIVATE SUB Age_Write(Value AS Byte)
>  IF Value >= MinAge THEN
>    iAge = Value
>  ELSE
>     Error.Raise("Age have to equal or greater than: " & MinAge)
>  ENDIF
> END
>
> PUBLIC SUB DoSomething()
>  . . .
> END
>
> PUBLIC FUNCTION DoSomethingElse() AS String
>  . . .
> END
>
> PRIVATE SUB DoSomething1()
>  . . .
> END
>
> PRIVATE FUNCTION DoSomethingElse1() AS String
>  . . .
> END
>
> -----------------
>
> Become:
>
>
> INTERFACE
>
>  'Attribute keyword is optional
>  ATTRIBUTE Name, LastName AS String
>
>  'Defines an attribute that is part of interface class and is
> accessed by dot notation (AnObject.Age, AnObject.Age=34)
>  PROPERTY Age AS Byte
>    'Validate when property is written (WHEN WRITE is optional because
> is the default)
>    'When Write: just in case, so When Read could exist too.
>    VALIDATE WHEN WRITE Age >= MinAge
>      'Unsucessfull is a long word, may be there's other better
>      UNSUCESSFULL Error.Raise("Age have to equal or greater than: " & MinAge)
>
>  'METHOD keyword is optional
>  METHOD DoSomething()
>    . . .
>  END
>
>  METHOD DoSomethingElse() AS String
>    . . .
>  END
>
>
> IMPLEMENTATION
>
>  CONST MinAge AS Byte = 28
>
>  . . .
>
>  'Same name is used in INTERFACE: this would possible because the
> scope is different
>  METHOD DoSomething()
>    . . .
>  END
>
>  METHOD DoSomethingElse() AS String
>    . . .
>  END
>
> ------------
> Advantages
>
> * More expressive code (smells a bit declarative)
> * Is needed to write less code (50% in this example)
> * keywords are closer to OOP
> * More easy to teach
>
> Disadvantages
>
> * This code not seems BASIC neither Gambas (that is why this syntax
> should be alternative)
> * Is difficult to implement?
>
>
> What do you think?
>
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing.
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



-- 
Fabien Bodard




More information about the User mailing list