design - Printing standard in raw implementations -
i'm making little toy stack-language, , revolving around central concept of bytecode, literally jvm.
one of opcodes want add in, print_var
function, print value of local variable. question is, print function use? println()
, or print()
?
well really, it's not question of use, what standard in actual applications of process? systems designed print()
, , println()
function built around print()
function, or both made hand-in-hand seperate things?
i'm taking @ java's printwriter
source, used in system.out.println()
, , defined follows:
public void println(boolean x) { synchronized (lock) { print(x); println(); } }
obviously java made print()
function , based println()
off of it. many other major languages that?
let's see:
- c: has printf --- no println
- c++: has ostream -- no println
- c#: has writeline (and write)
- haskell: has putstr , putstrln ...
long story short: can find both. implement you think works best requirements respectively approach in general. in other words: have @ other opcodes have/want implement , assess if more "convenience" (so have print , println), or if focus on providing "elementary building blocks" (then might provide print).
beyond that: keep in mind providing println() has 1 major advantage: user doesn't need worry different "new line" characters different operating systems.
Comments
Post a Comment