From: Jordan DeLong Date: Mon, 24 Sep 2012 20:58:28 +0000 (-0700) Subject: Add a FAQ item about dynamic strings X-Git-Tag: v0.22.0~1178 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e825366c06e7ab908129d0a527fc62344ef858b1;p=folly.git Add a FAQ item about dynamic strings Summary: After a conversation with njormrod I remembered why we didn't do this. Let's document it. Test Plan: It's docs. Reviewed By: njormrod@fb.com FB internal diff: D582651 --- diff --git a/folly/docs/Dynamic.md b/folly/docs/Dynamic.md index c9a5c365..924bb714 100644 --- a/folly/docs/Dynamic.md +++ b/folly/docs/Dynamic.md @@ -186,6 +186,17 @@ also be surprising if `dynamic d` left `d.isArray()` as true. The solution was just to disallow uninitialized dynamics: every dynamic must start out being assigned to some value (or nullptr). +**Q. Why doesn't a dynamic string support begin(), end(), and operator[]?** + +The value_type of a dynamic iterator is `dynamic`, and `operator[]` +(or the `at()` function) has to return a reference to a dynamic. If +we wanted this to work for strings, this would mean we'd have to +support dynamics with a character type, and moreover that the internal +representation of strings would be such that we can hand out +references to dynamic as accessors on individual characters. There +are a lot of potential efficiency drawbacks with this, and it seems +like a feature that is not needed too often in practice. + **Q. Isn't this just a poor imitation of the C# language feature?** Pretty much.