Commit 1e718d7
Document critical string vs char type distinction in Zephir
Added comprehensive documentation clarifying the important differences
between string and char types in Zephir:
**Key Additions:**
1. **Type System Section Enhancements:**
- Clarified that char uses single-quote syntax: 'A'
- Emphasized that string indexing (str[i]) returns char, not string
- Added that string must use double-quote syntax: "hello"
- Noted that single quotes are exclusively for char type
2. **New Dedicated Section: "String vs Char: Key Distinctions":**
- Syntax difference table (single vs double quotes)
- Detailed explanation of array access returning char
- Practical examples showing string iteration yields char types
- Type conversion examples (char to string and vice versa)
- Common pitfall example showing incorrect char/string comparison
3. **Coding Guidelines Update:**
- Added reminder that string indexing returns char type
- Emphasized quote usage: single for char, double for string
4. **Common Pitfalls Section:**
- Added "String vs Char Confusion" as item #3
- Listed specific gotchas:
* str[0] is char type, not string
* Quote syntax requirements
* Loop variable type when iterating strings
* Correct comparison syntax
This addresses a critical type distinction that can cause confusion
for developers new to Zephir, especially those coming from PHP where
this distinction doesn't exist.1 parent dfbd7a3 commit 1e718d7
1 file changed
+83
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
292 | | - | |
293 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
294 | 297 | | |
295 | 298 | | |
296 | 299 | | |
| |||
303 | 306 | | |
304 | 307 | | |
305 | 308 | | |
306 | | - | |
307 | | - | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
308 | 312 | | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
309 | 378 | | |
310 | 379 | | |
311 | 380 | | |
| |||
1697 | 1766 | | |
1698 | 1767 | | |
1699 | 1768 | | |
| 1769 | + | |
| 1770 | + | |
1700 | 1771 | | |
1701 | 1772 | | |
1702 | 1773 | | |
| |||
1759 | 1830 | | |
1760 | 1831 | | |
1761 | 1832 | | |
1762 | | - | |
1763 | | - | |
1764 | | - | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
1765 | 1841 | | |
1766 | 1842 | | |
1767 | 1843 | | |
| |||
0 commit comments