Re: Aw: Re: [feature wishl] stdin and stdout
[Thread Prev] | [Thread Next]
- Subject: Re: Aw: Re: [feature wishl] stdin and stdout
- From: Ori Bernstein <ori@xxxxxxxxxxxxxx>
- Date: Sun, 27 Dec 2015 00:14:21 -0800
- To: a.regenfuss@xxxxxx
- Cc: myrddin-dev@xxxxxxxxxxxxxx
[Putting this back on the list, as others may find the bit about __init__ useful] On Sat, 26 Dec 2015 23:02:32 +0100, a.regenfuss@xxxxxx wrote: > > >Where/what APIs are you interested in adding? Are you suggesting > >bio provide bio.^(In Out Err), or something more than that? > > I guess bio seems to be the right place, because it works well > with bio.^(In Out Err) as file structures and not only as file > descriptors. Well, sort of. Unlike C's stdin/stdout/stderr, there is no automatic flushing with Myrddin bio: You must either close or explicitly flush the streams yourself. So they're not direct replacements. > About the implementation: I guess just opening "/dev/stdin" > would not be enough since this is not guaranteed to be portable. What problem, exactly, are you trying to solve? > One possible solution to this would be opening the file-descriptor [0, 1, 2] > (like you did in std.put) when bio is started. The operating system opens fd 0, 1, 2 for you at program start on all Unixy systems; For now, at least, that should be safe to use. It might be better to add symbolic constants for it -- I'd accept a patch. > But I have no idea how I would do that without introducing something like > bio.init(). > > But since you are the language creator, maybe you have got an idea. Myrddin supports module initializer functions: const __init__ = { ...setup code... } may appear once per file. This initializer will run before main. In fact, more specifically, the __init__ functions are ordered topologically, such that each __init__ will be run exactly once, after the __init__ functions of its dependencies (if any), and before any __init__ functions which depend on it. The order that the dependencies are initialized in is not guaranteed. For an example, take a look at lib/std/fmtfuncs.myr -- Ori Bernstein
[feature wishl] stdin and stdout | a.regenfuss@xxxxxx |
Re: [feature wishl] stdin and stdout | Ori Bernstein <ori@xxxxxxxxxxxxxx> |
- Prev by Date: Re: [feature wishl] stdin and stdout
- Next by Date: The website overflows on Android
- Previous by thread: Re: [feature wishl] stdin and stdout
- Next by thread: Re: Generic Impls: Thinking Out Loud
- Index(es):