notes-computer-programming-programmingLanguagesBook-programmingLanguagesPartConstructs

Table of Contents for Programming Languages: a survey

Part III: Language constructs and features

Chapter : data

bool

fixed length list (array)

list

S-expression

dict/associative array/hashtable

what can be a key? can you add hash fns to custom data?

struct/record

enum

http://docs.python.org/dev/library/enum.html

note: this link describes the benefits of enums over just using preprocessor macros, e.g. C #defines: http://codingrelic.geekhold.com/2008/10/ode-to-enum.html

multidim array/table

dataframe

string

unicode? bytestring?

string interpolation

some syntaxes:

"$x" e.g Perl

"{x}" e.g. Hoon

"%d" % (x) e.g. Python

"\(x)" e.g. Yeti, Apple Swift

regex

int, real

arbitrary precision arith

sized vs. mathy numeric types

pattern matching

ML, Haskell

OMeta: parsing on data http://www.vpri.org/pdf/tr2008003_experimenting.pdf

in an object-oriented language without reflection or pattern-matching, the only way to make behavior conditional upon object class is through methods (which are polymorphic on the type of the object they are a part of). In such a case, if it is desired for the behavior of a method depend on its arguments, the Visitor pattern can be used (e.g.

" package syntax;

abstract class ExpressionVisitor? { abstract void visitIntExp(IntExp? e); abstract void visitAddExp(AddExp? e); }

abstract class Expression { abstract void accept(ExpressionVisitor? v); }

class IntExp? extends Expression { int value;

  void accept(ExpressionVisitor v)
  {
    v.visitIntExp(this);
  }}

class AddExp? extends Expression { Expression e1, e2;

  void accept(ExpressionVisitor v)
  {
    v.visitAddExp(this);
  }}

The interest of this construction is that it is now possible to define operations on expressions by subclassing ExpressionVisitor?. This can even be done in a different package, without modifying the expression hierarchy classes.

Behaviour can now be defined on Expressions

package tools;

class PrettyPrint? extends ExpressionVisitor? { void visitIntExp(IntExp?