[Gambas-user] Suggestions 4 new keywords

Fabián Flores Vadell fabianfloresvadell at ...626...
Fri Sep 17 03:28:32 CEST 2010


2010/9/16 Benoît Minisini <gambas at ...1...>:
>> > So, replacing one word (for example PUBLIC) by another (ATTRIBUTE),
>> > whereas the implementation is the same behind is not a good idea,
>> > because then this is not BASIC anymore.
>>
>> I'm never said that PUBLIC would be replaced by ATTRIBUTE. That have no
>> sense.
>
> I mean that declaring a public variable with PUBLIC or with ATTRIBUTE is
> always declaring a public variable, with another keyword.

But keyword have a meaning. Words are the starting point for reasoning
about something.

For example, the keyword PUBLIC refers to the scope of a variable, so
evokes a concept that come from structured programming. Instead,
INTERFACE is an important concept that when you use PUBLIC remains
hided. But also, INTERFACE refers to the encapsulation, so evokes a
concept that was highly emphasized by OOP.

Similarily, FUNCTION, SUB and PROCEDURE evokes to the structured
programming. Instead, METHOD evokes to the OOP.

So, words are very important because allow linking the syntax with the
concepts, and this matters to allow good reasoning (specially at the
moment than is necesary teach an OOP language).


>> That is not an impediment to an alternative syntax. In fact, Gambas
>> have alternative syntax for many things:
>>
>> - Loops
>> - String functions (VB component)
>>
> The two cases are just exceptions

There are more than two: PROCEDURE and SUB for example.

> Otherwise, I try to limit the number of keywords as much as possible.

That can be important. But, is more important that provide keywords
closer to OOP?

So if you has admited exceptions before. Why you can't do now?

> It is what I meant: a special syntax to define something not so frequent. You
> take the case where your "property" is actually just a bit more than a
> variable. This is actually rarely the case. Reading is often just returning
> the contents of a variable, but writing is usually more complex. I don't know
> how to cover all possible cases with less keywords than the current syntax.

The problem is that if I define, for example:

PUBLIC Age AS Byte

PUBLIC SUB setAge(Value AS Byte)
  IF Value >= MinAge AND Value <= MaxAge THEN Age = Value
END

The user can avoid the validation, just using the dot notation.

This is because the PUBLIC keyword refers to the scope, but if you
think about that as part of an interface, you can do mandatory the
validation (execution of setAge) for the dot notation too. So, there's
no need to force to programmer to write an private attribute, setter
and getter or property and _Write _Read methods.

Do it so, can be confusing because scope concept isn't equal to
interface concept.

May be that can be more clear, so:

PUBLIC '(a.k.a. Interface)
  Age AS Byte

  SUB setAge(Value AS Byte)
    IF Value >= MinAge AND Value <= MaxAge THEN Age = Value
  END

So it is clear that both the attribute and the method are part of the
interface and the method will be executed when the attribute gets a
value.

But if you want less keywords, you can do:

PUBLIC '(a.k.a. Interface)
  Age AS Byte

  setAge(Value AS Byte)
    IF Value >= MinAge AND Value <= MaxAge THEN Age = Value
  END

Because, I think than, a method (procedure or function) is defined by
its signature, not by the prefix keywords FUNCTION, PROCEDURE or SUB.

May be, you want to do optionals these keywords.

>> > Note that I am not agree with the common separation between "interface"
>> > and "implementation". In the real life, they are not separated. A good
>> > interface usually leads directly to the implementation. Or the interface
>> > surface from a good implementation. :-)
>>
>
> When I mean "real life", I mean "real programming life". :-)

Anyway, I don't understand what you mean.

>> (read below of "or much better")
>>
>> http://old.nabble.com/Ideas4Gambas-to28782834.html
>
> Sorry, I didn't know you were the father. :-)

lol. Luckily, I'm a real father.

Finally, I think that you can do Gambas become more easy yet (easy to
code, easy to reasoning, easy to teach), and the syntax can be a
important part in that. So, you know how to do it the best way,
because you're the expert not me.

Regards

-- 
Fabián Flores Vadell
www.speedbooksargentina.blogspot.com




More information about the User mailing list