DOT is Copyright (c) 2009 by Jeremy Cowgar
Copyright (c) 1998 by David Cuny
DOT is released under the same License as Euphoria itself.
DOT is a pre-processor that allows the use of dot notation for function, procedure and sequence access in Euphoria, giving it a very object-oriented feel. DOT does not provide true object-oriented capabilities, but it does put a very interesting spin on Euphoria code making many tasks easier, clearer and more concise.
To use DOT, type:
exwc dot filename
exwc can be subsituted for your interpreter, i.e. ex or exu.
filename is the name of the file to process. The common naming scheme DOT files is:
You can setup a makefile to automatically pre-process your source files when they have changed.
TODO: Give example makefiles for unix make and watcom's wmake
DOT lets you write functions and procedures in the form
<arg> = <routine>( <arg> ... )as
<arg>.<routine>( ... )If a function is written outside an expression, it is assumed to be an assigment, and will be expanded as such.
s.append(1) -- s = append( s, 1 ) a = b.append(2) -- a = append( b, 2 ) point[1].add(12) -- point[1] = add( point[1], 12 ) a = b.length() -- a = length(b)
Version 2.0 adds DOT access to sequences which in combination with enums added in Euphoria 4.0 makes for nice sequence access. DOT lets you write sequence access in the form
<value> = <sequence>[<index>]as
<value> = <sequence>.<index>index can be a number, variable, constant or enum. Further, you can stack index entries on the end for multiple depth access in the form of
<value> = <sequence>.<index1>.<index2>
Some examples
enum first_name, last_name, age sequence person = { "John", "Doe", 43 } ? person.1 -- ? person[1] ? person.first_name -- ? person[first_name]
You can also assign values to a sequence using the DOT notation
<sequence>[<index>] = <value>as
<sequence>.<index> = <value>
Some examples
enum first_name, last_name, age sequence person = { "John", "Doe", 43 } person.1 = "Jim" -- person[1] = "Jim" person.first_name = "Jim" -- person[first_name] = "Jim" person.age = 68 -- person[age] = 68
You can also treat sequences as normal values and call functions and/or procedures on the value.
Some examples
enum id, first_name, last_name, age sequence people = { { -1, "John", "Doe", 93 }, { -1, "Jane", "Smith", 43 }, { -1, "Jack", "Jones", 12 } } for i = 1 to people.length() do -- length(people) people.i.id = i -- people[i][id] = i ? people.i.first_name.length() -- ? length(people[i][first_name]) people.i.first_name.trim() -- people[i][first_name] = trim(people[i][first_name]) people.i.last_name.head(10) -- people[i][last_name] = head(people[i][last_name], 10) other = people.i.first_name.upper() -- other = upper(people[i][first_name]) end for
DOT will automatically translate include myfile.de to include myfile.e when it processes the file. You must, of course, also translate myfile.de so that myfile.e is written and can be included when your application runs.
Please see the examples directory for working examples and working makefiles to automate your project with DOT.
Did you find this interesting/useful/amusing? Would you like to see this added to PP? Need more documentation?
Send me an e-mail at: jeremy (nospam dot) cowgar (dot) com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.