Property (programming) - Support in Languages

Support in Languages

Programming languages that support properties include ActionScript 3, C#, D, Delphi/Free Pascal, F#, JavaScript, Objective-C 2.0, Python, Scala, Vala, and Visual Basic. Some object-oriented languages, such as Java, don't support properties, and require the programmer to define a pair of accessor and mutator methods instead. Oberon-2 provides an alternative mechanism using object variable visibility flags. Other languages designed for the Java Virtual Machine, such as Groovy, do natively support properties. While C++ doesn't have first class properties, they can be emulated due to operator overloading. Also note that some C++ compilers support first class properties (the Microsoft C++ compiler as an example).

In most languages, properties are implemented as a pair of accessor/mutator methods, but accessed using the same syntax as for public fields. Omitting a method from the pair yields a read-only or an uncommon write-only property.

In some languages with no built-in support for properties, a similar construct can be implemented as a single method that either returns or changes the underlying data, depending on the context of its invocation. Such techniques are used e.g. in Perl.

Some languages (Ruby, Smalltalk) achieve property-like syntax using normal methods, sometimes with a limited amount of syntactic sugar.

Read more about this topic:  Property (programming)

Famous quotes containing the words support and/or languages:

    There is much to support the view that it is clothes that wear us, and not we, them; we may make them take the mould of arm or breast, but they mould our hearts, our brains, our tongues to their liking.
    Virginia Woolf (1882–1941)

    People in places many of us never heard of, whose names we can’t pronounce or even spell, are speaking up for themselves. They speak in languages we once classified as “exotic” but whose mastery is now essential for our diplomats and businessmen. But what they say is very much the same the world over. They want a decent standard of living. They want human dignity and a voice in their own futures. They want their children to grow up strong and healthy and free.
    Hubert H. Humphrey (1911–1978)