properties # allow us to override that and provide our own names, in this case get_name and set_name has 'name' => (is => 'rw', isa => 'Str', reader => 'get_name', writer => 'set_name'); 1; PHP PHP defines the "magic methods" __getand__set for properties of objects. In this example of a simple class representing a student with only the name stored, one can see the variable name is private, i.e. only visible from the Student class, and the "setter" and "getter" is public, namely the getName() and setName('name') methods. class Student { private string $name; /** * @return string The name. */ public function getName(): string { return $this->name; } /** * @param string $newName The name to set. */ public function setName(string $newName): void { $this->name = $newName; } } Python This example uses a Python class with one variable, a getter, and a setter. class Student: # Initializer def __init__(self, name: str) -> None: # An instance variable to hold the student's name self._name = name # Getter method @property def name(self): return self._name # Setter method @name.setter def name(self, new_name): self._name = new_name >>> bob = Student("Bob") >>> bob.name Bob >>> bob.name = "Alice" >>> bob.name Alice >>> bob._name = "Charlie" # bypass the setter >>> bob._name # bypass the getter Charlie Racket In Racket, the object system is a way to organize code that comes in addition to modules and units. As in the rest of the language, the object system has first-class values and lexical scope is used to control access to objects and methods. #lang racket (define student% (class object% (init-field name) (define/public (get-name) name) (define/public (set-name! new-name) (set! name new-name)) (super-new))) (define s (new student% [name "Alice"])) (send s get-name) ; => "Alice" (send s set-name! "Bob") (send s get-name) ; => "Bob" Struct definitions are an alternative way to define new types of values, with mutators being present when explicitly required: #lang racket (struct student (name) #:mutable) (define s (student "Alice")) (set-student-name! s "Bob") (student-name s) ; => "Bob" Ruby In Ruby, individual accessor and mutator methods may be defined, or the metaprogramming constructs attr_reader or attr_accessor may be used both to declare a private variable in a class and to provide either read-only or read-write public access to it respectively. Defining individual accessor and mutator methods creates space for pre-processing or validation of the data class Student def name @name end def