Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Pseudocode for different ways nice programming by context could work:
- My initial suggestion was this:
- if c < 0: it.le else: it.ri
- if context == nil:
- context = n
- return
- it = context
- Here you have a variable context that is automatically created in the same manner result is for functions.
- Since then I learned about byAddr (formerly known as byRef), and if I'm correct about it is used it would look like this:
- byAddr context = if c < 0: it.le else: it.ri
- if context == nil:
- context = n
- return
- it = context
- There are three differences here:
- 1) explicit use of byAddr which also has other uses and can be used by other means than if.
- 2) the context variable name is programmer defined, not by convention, this makes the code longer,
- but also enables nesting of this concept
- 3) there's no idented block, which I see as a disadvantage, because it signified where the context is
- relevant, for this block of code only and not for what follows, which is the idea of "context"
- But this is also a matter of taste, ..., could be good as well
Advertisement
Add Comment
Please, Sign In to add comment