From e825366c06e7ab908129d0a527fc62344ef858b1 Mon Sep 17 00:00:00 2001 From: Jordan DeLong Date: Mon, 24 Sep 2012 13:58:28 -0700 Subject: [PATCH] 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 --- folly/docs/Dynamic.md | 11 +++++++++++ 1 file changed, 11 insertions(+) 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. -- 2.34.1