After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 641268 - Support for Python-like slice syntax
Support for Python-like slice syntax
Status: RESOLVED DUPLICATE of bug 571352
Product: vala
Classification: Core
Component: Parser
0.11.x
Other Linux
: Normal enhancement
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks: 641267
 
 
Reported: 2011-02-02 17:17 UTC by Marco Trevisan (Treviño)
Modified: 2011-03-15 01:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
valaparser: support for Python-like slice syntax (1.72 KB, patch)
2011-02-02 17:17 UTC, Marco Trevisan (Treviño)
none Details | Review

Description Marco Trevisan (Treviño) 2011-02-02 17:17:17 UTC
Created attachment 179906 [details] [review]
valaparser: support for Python-like slice syntax

The vala slice syntax is similar to python, but it doesn't allow to use defaults start/stop values like python (i.e.: array[start:], or array[:stop]).

This patch fixes it, allowing to use slicing functions like:
	string word = "Hello World";
	print(word[:2]+"\n");
	// alias for:
	print(word[0:2]+"\n");

	print(word[2:]+"\n");
	// alias for:
	print(word[2:0]+"\n"); // 0 stands for word.length, see #639586

For strings support it needs the patch which fixes the Bug 639586
For arrays complete support it needs the patch which fixes the Bug 641267
Comment 1 Luca Bruno 2011-02-28 10:35:44 UTC
Hi, word[2:] should be an alias for word[2:word.length], otherwise it's not consistent with the first index.
Comment 2 Marco Trevisan (Treviño) 2011-03-15 01:12:56 UTC
I guess this can be closed, more on bug 571352

*** This bug has been marked as a duplicate of bug 571352 ***