scribble-foreach-experiment

command module
v0.0.0-...-b00d1d8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2018 License: MIT Imports: 7 Imported by: 0

README

scribble-foreach-experiment

Foreach primitive experiment with Scribble Go API.

proto

Foreach loop states (current index, number of iterations) are kept in memory during execution as a package-scope stack. The basic algorithm is as follows:

  1. The stack fes (foreach stack) is initialised with protocol package
  2. A foreach state s0 is entered, either
    • User calls s0.Foreach(), either
      • (First time) New foreach pushed on fes setting number of iterations, current = 1
      • (Subsequent) increment current, check that current is < number of iterations,
        • Loop body follows from Foreach(), when reached end of body, go back to s0
    • User calls s0.EndForeach(), check that current = number of iterations, then pop fes

Some potential improvements:

  • The protocol package proto cannot be used concurrently, this should be changed in the final implementation such that fes is attached to the instance of protocol (e.g. initialised with Proto.New())
  • HasNext and Foreach are clumsy

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package final is the final design of the foreach API.
Package final is the final design of the foreach API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL