1. 'split' declared more than once

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 ?

new topic     » topic index » view message » categorize

2. Re: 'split' declared more than once

rneu said...

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: 'split' declared more than once

_tom said...

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:

regex:split()

include std/regex.e 
namespace regex 
public function split(regex re, string text, integer from = 1, option_spec options = DEFAULT) 

stdseq:split()

include std/sequence.e 
namespace stdseq 
public function split(sequence st, object delim = ' ', integer no_empty = 0, integer limit = 0) 

-Greg

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu