Browse files

Add a FAQ item about dynamic strings

After a conversation with njormrod I remembered why we didn't
do this.  Let's document it.

Test Plan: It's docs.

Reviewed By:

FB internal diff: D582651
  • Loading branch information...
1 parent 992f3b8 commit e825366c06e7ab908129d0a527fc62344ef858b1 @jdelong jdelong committed Sep 24, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 folly/docs/
@@ -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.

0 comments on commit e825366

Please sign in to comment.