# Std::io::seek

**URL:** <https://internals.rust-lang.org/t/std-seek/8472>\
**Category:** Uncategorized\
**Created:** [September 24, 2018, 10:28pm UTC](https://internals.rust-lang.org/t/std-seek/8472 "2018-09-24T22:28:39Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xpyder](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/xpyder/32/4366_2.png) [@Xpyder](https://internals.rust-lang.org/u/Xpyder)\
**Post date:** [September 24, 2018, 10:28pm UTC](https://internals.rust-lang.org/t/std-seek/8472/1 "2018-09-24T22:28:39Z")

</div>

[std::io::seek](https://doc.rust-lang.org/std/io/trait.Seek.html)

> A seek beyond the end of a stream is allowed, but implementation defined.

should probably be

> A seek beyond the end of a stream is allowed, but behavior is undefined.

Not sure if this is where I'm supposed to post this, but it's the closest I'm currently aware of

---

<div class="post-metadata">

**Author:** ![cuviper](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/cuviper/32/1897_2.png) [@cuviper](https://internals.rust-lang.org/u/cuviper)\
**Post date:** [September 24, 2018, 10:37pm UTC](https://internals.rust-lang.org/t/std-seek/8472/2 "2018-09-24T22:37:49Z")

</div>

You could submit such a change as a pull request on [https://github.com/rust-lang/rust/](https://github.com/rust-lang/rust/).

However, the usual meaning of [undefined behavior](https://en.wikipedia.org/wiki/Undefined_behavior) does not apply to this case. UB is unsafe and should be avoided altogether, whereas implementation-defined behavior just means that some systems will handle this differently than others.

---

<div class="post-metadata">

**Author:** ![Xpyder](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/xpyder/32/4366_2.png) [@Xpyder](https://internals.rust-lang.org/u/Xpyder)\
**Post date:** [September 24, 2018, 10:39pm UTC](https://internals.rust-lang.org/t/std-seek/8472/3 "2018-09-24T22:39:01Z")

</div>

oh, so “implementation defined” is known specific terminology? I thought it was a grammatical mistake

---

<div class="post-metadata">

**Author:** ![cuviper](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/cuviper/32/1897_2.png) [@cuviper](https://internals.rust-lang.org/u/cuviper)\
**Post date:** [September 24, 2018, 10:43pm UTC](https://internals.rust-lang.org/t/std-seek/8472/4 "2018-09-24T22:43:23Z")

</div>

Yes, it’s an industry term – here’s [implementation-defined behavior](https://en.wikipedia.org/wiki/Unspecified_behavior#Implementation-defined_behavior). These links mostly talk about C and C++, but Rust uses the same terminology, especially since LLVM is first and foremost a C and C++ backend.

If you think this could be confusing to unfamiliar users, it might be worth adding some clarification.

---

<div class="post-metadata">

**Author:** ![gbutler](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/gbutler/32/3670_2.png) [@gbutler](https://internals.rust-lang.org/u/gbutler)\
**Post date:** [September 24, 2018, 10:45pm UTC](https://internals.rust-lang.org/t/std-seek/8472/5 "2018-09-24T22:45:45Z")

</div>

No, “Implementation Defined Behavior” and “Undefined Behavior” are definitely different things and terms of art. “Implementation Defined” usually refers to something which will not be the same across implementations, but, that will have a definite, safe behavior on a given implementation, whereas, “Undefined Behavior” refers to something where even a specific implementation will not specifically define what will occur and, in fact, anything at all is free to occur, hence making it unsafe.

---

<div class="post-metadata">

**Author:** ![Xpyder](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/xpyder/32/4366_2.png) [@Xpyder](https://internals.rust-lang.org/u/Xpyder)\
**Post date:** [September 24, 2018, 11:25pm UTC](https://internals.rust-lang.org/t/std-seek/8472/6 "2018-09-24T23:25:27Z")

</div>

> [@cuviper](#):
>
> Yes, it’s an industry term – here’s [implementation-defined behavior](https://en.wikipedia.org/wiki/Unspecified_behavior#Implementation-defined_behavior) [...] If you think this could be confusing to unfamiliar users, it might be worth adding some clarification.

I didn't realize, maybe something like this then?

> A seek beyond the end of a stream is allowed, but it is implementation-defined.

the hyphen makes it clear "implementation defined" is a known concept (and matches it's usage elsewhere) and the "it is" makes it a bit more clear that the full sentence is considered and intentional.

While normally I find brevity improves clarity, in this case if you don't realize "implementation defined" is a single concept, it sounds like a thought that trailed off after an edit

---

<div class="post-metadata">

**Author:** ![steveklabnik](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/steveklabnik/32/4524_2.png) [@steveklabnik](https://internals.rust-lang.org/u/steveklabnik)\
**Post date:** [September 25, 2018, 12:05am UTC](https://internals.rust-lang.org/t/std-seek/8472/7 "2018-09-25T00:05:28Z")

</div>

I’d take a PR for that.

---

<div class="post-metadata">

**Author:** ![dcarosone](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/dcarosone/32/5244_2.png) [@dcarosone](https://internals.rust-lang.org/u/dcarosone)\
**Post date:** [September 25, 2018, 12:09am UTC](https://internals.rust-lang.org/t/std-seek/8472/8 "2018-09-25T00:09:12Z")

</div>

> A seek beyond the end of a stream is allowed, but the **effect** is implementation-defined.

FSVO of "effect" that might be "behaviour", "result", or suitable synonym.

---

<div class="post-metadata">

**Author:** ![Centril](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/centril/32/3334_2.png) [@Centril](https://internals.rust-lang.org/u/Centril)\
**Post date:** [September 25, 2018, 1:34am UTC](https://internals.rust-lang.org/t/std-seek/8472/9 "2018-09-25T01:34:09Z")

</div>

I would clarify this as:

> A seek beyond the end of a stream is allowed, but is defined by each implementation of the `Seek` trait.

which is more unambiguous.

---

<div class="post-metadata">

**Author:** ![glandium](https://avatars.discourse-cdn.com/v4/letter/g/3d9bf3/32.png) [@glandium](https://internals.rust-lang.org/u/glandium)\
**Post date:** [September 25, 2018, 2:54am UTC](https://internals.rust-lang.org/t/std-seek/8472/10 "2018-09-25T02:54:31Z")

</div>

> [@Centril](#):
>
> I would clarify this as:
> 
> > A seek beyond the end of a stream is allowed, but is defined by each implementation of the `Seek` trait.
> 
> which is more unambiguous.

OTOH, the implementations docs are a) hidden by default b) don't say what the implemented behavior is. Funnily enough, it's likely that for `File`, the behavior is implementation-defined at the OS level.

---

<div class="post-metadata">

**Author:** ![Xpyder](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/xpyder/32/4366_2.png) [@Xpyder](https://internals.rust-lang.org/u/Xpyder)\
**Post date:** [September 25, 2018, 5:00pm UTC](https://internals.rust-lang.org/t/std-seek/8472/11 "2018-09-25T17:00:31Z")

</div>

I’m a bit out of practice on doing PRs so I [opened it as an issue](https://github.com/rust-lang/rust/issues/54562) over on Github.

---

<div class="post-metadata">

**Author:** ![Ixrec](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/ixrec/32/6754_2.png) [@Ixrec](https://internals.rust-lang.org/u/Ixrec)\
**Post date:** [September 25, 2018, 5:06pm UTC](https://internals.rust-lang.org/t/std-seek/8472/12 "2018-09-25T17:06:19Z")

</div>

With terms of art like “undefined behavior” and “implementation defined” that we really have to use in documentation, yet not everyone is aware they have a very specific well-known definition, I think the only complete solution would be to make all uses of them in official documentation links to a standard glossary or FAQ entry or something.

---

<div class="post-metadata">

**Author:** ![Xpyder](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/xpyder/32/4366_2.png) [@Xpyder](https://internals.rust-lang.org/u/Xpyder)\
**Post date:** [September 25, 2018, 5:38pm UTC](https://internals.rust-lang.org/t/std-seek/8472/13 "2018-09-25T17:38:34Z")

</div>

> [@Ixrec](#):
>
> ... would be to make all uses of them in official documentation links to a standard glossary or FAQ entry

That's not a bad idea for the larger picture.

I think in this case the hyphen and additional wording are enough to make it clear it's a considered sentence and not leftovers from a previous edit

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [March 25, 2019, 8:30am UTC](https://internals.rust-lang.org/t/std-seek/8472/14 "2019-03-25T08:30:55Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
