1. 'split' declared more than once
- Posted by rneu Jun 28, 2017
- 1065 views
I am getting error that the function 'split' is declared more than once:
<0074>:: Errors resolving the following references: 'split' (myfile.eu:182) has been declared more than once. in /usr/share/euphoria/include/std/regex.e in /usr/share/euphoria/include/std/sequence.e
How can this be resolved if I have to use both regex.e and sequence.e ?
2. Re: 'split' declared more than once
- Posted by _tom (admin) Jun 28, 2017
- 1047 views
I am getting error that the function 'split' is declared more than once:
<0074>:: Errors resolving the following references: 'split' (myfile.eu:182) has been declared more than once. in /usr/share/euphoria/include/std/regex.e in /usr/share/euphoria/include/std/sequence.e
How can this be resolved if I have to use both regex.e and sequence.e ?
The solution is namespaces.
include std/regex.e as re include std/sequence.e as s
you may choose any namespace identifier re, reg, blue, dog, ...
this lets you write re:split and s:split since they are now unique identifiers
I've been working on a rant about std/search.e, yes it is messy.
_tom
3. Re: 'split' declared more than once
- Posted by ghaberek (admin) Jun 29, 2017
- 1058 views
The solution is namespaces.
include std/regex.e as re include std/sequence.e as s
The standard libraries in Euphoria 4.0 include namespaces and I recommend using those instead of declaring your own.
I suppose you could do that for shorthand, but it can become tedious to track custom namespacing in a larger project.
The original "include <file> as <namespace>" syntax is a throwback to before the addition of the namespace keyword.
You can see the default namespace in the declaration for each function:
include std/regex.e namespace regex public function split(regex re, string text, integer from = 1, option_spec options = DEFAULT)
include std/sequence.e namespace stdseq public function split(sequence st, object delim = ' ', integer no_empty = 0, integer limit = 0)
-Greg