Skip to content

Commit

Permalink
Add a FAQ item about dynamic strings
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jdelong committed Oct 12, 2012
1 parent 992f3b8 commit e825366
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions folly/docs/Dynamic.md
Expand Up @@ -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.