On Tuesday, 7 June 2016 at 20:55:12 UTC, Ola Fosheim Grøstad wrote:
repeat10:{
   N:<{ n:@int; do 10->n; inner; exit n};
   i:@int;
   do N -> iterate{ do inner; }
}

repeat99:repeat10{
  N:<{ do 99->n; inner; }
}

repeat99{ do i -> print; "bottles of wine" ->print }


Adding some comments, as the example was not clear on its own:

// repeat10 is a new pattern (class) inheriting from object by default
repeat10:{
    // N is a virtual pattern (function)
    N:<{ n:@int; do 10->n; inner; exit n};
do N -> iterate{ do inner; } // this is a subclass of the previously defined iterate pattern
}

// repeat99 is a new pattern inheriting from repeat10 above
repeat99:repeat10{
    // N is a specialization of N in repeat10
    // N expands to {n:@int; do 10->n; 99->n; inner; exit n}
   N:<{ do 99->n; inner; }
}

// this is a subclass of repeat 99
repeat99{ do i -> print; "bottles of wine" ->print }


Give or take, I haven't used Beta in 20 years. Abstractions is not the problem, a very simple language can provide what most programmers need. Perhaps not with a familiar syntax though.

Reply via email to