1. Conflicts with words

Hello

What is the simplest way to solve problems like this:

C:\1usre\sockets\connect.exw:25 
<0135>:: Syntax error - expected to see an expression, not a procedure 
success=close(sock) 
            ^ 

Thanks in advance

new topic     » topic index » view message » categorize

2. Re: Conflicts with words

sergelli said...

Hello

What is the simplest way to solve problems like this:

C:\1usre\sockets\connect.exw:25 
<0135>:: Syntax error - expected to see an expression, not a procedure 
success=close(sock) 
            ^ 

Thanks in advance

Use the namespace qualifier:

success=sockets:close(sock) 
new topic     » goto parent     » topic index » view message » categorize

3. Re: Conflicts with words

sergelli said...

Hello

What is the simplest way to solve problems like this:

C:\1usre\sockets\connect.exw:25 
<0135>:: Syntax error - expected to see an expression, not a procedure 
success=close(sock) 
            ^ 

Thanks in advance

 
 
    close(sock) 

The reason you are getting that error message is that an expression is meant to follow an '=' symbol but the close() routine is not an expression because it is a procedure, which means that it does not return a value. As close() cannot return a value, you can't use it to assign a value to the success variable.

Are you trying to see if the call to close() worked or not? You could try this ...

close(sock) 
if seek(sock,-1) = 1 then 
  -- file is closed 
end if 

Oh ... now I get it... you are trying to use the sockets library close and not the i/o close. In that case, use the namespace 'sockets'.

success=sockets:close(sock) 
new topic     » goto parent     » topic index » view message » categorize

4. Re: Conflicts with words

Thank you very much,

But, edit the file std/socket.e, and changing the word "close" to one that does not cause this type of problem would not be better?

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

5. Re: Conflicts with words

sergelli said...

Thank you very much,

But, edit the file std/socket.e, and changing the word "close" to one that does not cause this type of problem would not be better?

No, it would be much worse. You have now sabotaged your euphoria installation. Anything that you try to run that already uses that would fail. And you cannot easily share your code with anyone else.

In general, editing 3rd party code is a bad idea, since everyone who wants to use your code now has to have the modified version of that third party code. This is not the end of the world, but it's a lot more hassle than simply qualifying your use of that routine with a namespace qualifier.

Also, other people looking at your code may have more difficulty figuring out what you're doing, especially if you've changed something like the standard library.

Matt

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

6. Re: Conflicts with words

mattlewis said...

No, it would be much worse. You have now sabotaged your euphoria installation. Anything that you try to run that already uses that would fail. And you cannot easily share your code with anyone else.y if you've changed something like the standard library.

Matt

I thought it would be better, because, for example, changing "close" to "end", the size of the "EXE" resulting is lower than when using the namespace qualifier:

--success=end(sock)       -- .exe size = 316.416 
success=sockets:close(sock) -- .exe size = 316.928 
new topic     » goto parent     » topic index » view message » categorize

7. Re: Conflicts with words

sergelli said...
mattlewis said...

No, it would be much worse. You have now sabotaged your euphoria installation. Anything that you try to run that already uses that would fail. And you cannot easily share your code with anyone else.y if you've changed something like the standard library.

I thought it would be better, because, for example, changing "close" to "end", the size of the "EXE" resulting is lower than when using the namespace qualifier:

--success=end(sock)       -- .exe size = 316.416 
success=sockets:close(sock) -- .exe size = 316.928 

Hmm...I didn't think you could use end for a function name, being a reserved word. I get an error when I try that. I also wouldn't consider the size difference mentioned to be at all significant. And it causes all of the other trouble that I mentioned.

Matt

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

8. Re: Conflicts with words

mattlewis said...

Hmm...I didn't think you could use end for a function name, being a reserved word. I get an error when I try that. I also wouldn't consider the size difference mentioned to be at all significant. And it causes all of the other trouble that I mentioned.

Matt

Ok Thank you very much

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

9. Re: Conflicts with words

sergelli said...

Hello

What is the simplest way to solve problems like this:

C:\1usre\sockets\connect.exw:25 
<0135>:: Syntax error - expected to see an expression, not a procedure 
success=close(sock) 
            ^ 

Thanks in advance

If you are going to need the use of this specific syntax frequently,
you could pre-define a new function "closed" in your own work.

function closed(sock)  -- or public function 
  return sockets:close(sock) 
end function 
 

Then instead of using "close" use "closed" as your function

success=closed(sock) 

This way you are not disturbing the std\socket.e library and not having to use the namespace prefix in your work except once in the definition of the function "closed"

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

Search



Quick Links

User menu

Not signed in.

Misc Menu