1. SLASH should not be a builtin

should be a user environment defined thing, not a built-in. I assume this is somehow defined at parse time, or at euphoria exwc compile time. but how can it be overridden?

same with the defaut linefeed. directory separator etc. yes, it's somehow less complicated to not have to include a types.e or a std/filesys.e or os.e, to have to guess where it would be defined, for maybe 99% of the users, but if you run with a bash emulation shell on windows, the defaults euphoria thinks it is sure about become wrong. and there is no recourse.

override SLASH = '/' should work but doesn't does it really have to be a built-in?

new topic     » topic index » view message » categorize

2. Re: SLASH should not be a builtin

ne1uno said...

does it really have to be a built-in?

The documentation is wrong. SLASH is not a built in symbol.

See around line 126 in filesys.e ...

ifdef UNIX then 
	public constant SLASH='/' 
	public constant SLASHES = "/" 
	public constant CRLF = "\n" 
	public constant PATHSEP = ':' 
elsedef 
	public constant SLASH='\\' 
	public constant SLASHES = ":\\/" 
	public constant CRLF = "\r\n" 
	public constant PATHSEP = ';' 
end ifdef 
new topic     » goto parent     » topic index » view message » categorize

3. Re: SLASH should not be a builtin

DerekParnell said...
ne1uno said...

does SLASH etc really have to be a built-in?

The documentation is wrong. SLASH is not a built in symbol. See around line 126 in filesys.e ...

ok, thanks. at least I can limit propagation of those constants when I have access to the source and include files if necessary.

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

4. Re: SLASH should not be a builtin

ne1uno said...

ok, thanks. at least I can limit propagation of those constants when I have access to the source and include files if necessary.

I'm not understanding the problem with them, can you say why it's a problem for Euphoria to define them for you?

Jeremy

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

5. Re: SLASH should not be a builtin

CRLF is an example of the poorest naming in the library so far. CR LF literally mean \r\n, not anything else, no matter what OS you are on. The ASCII chart will show CR and LF as simple those two characters. This is not a DOS/Windows convention but that is THE definition of CR and LF. Instead of calling it CRLF, why not rename it to EOL end of line? That is what it is used for, after all. How should we define EOL for OSX? Shouldn't it be CR?

Shawn Pringle

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

6. Re: SLASH should not be a builtin

SDPringle said...

CRLF is an example of the poorest naming in the library so far.

I think I can come up with some other contenders ... blink

SDPringle said...

Instead of calling it CRLF, why not rename it to EOL end of line?

Good idea. If its not going to be a problem I'll get it done.

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

7. Re: SLASH should not be a builtin or constant

should be a user environment defined thing, not a constant.

if you run with a bash emulation shell on windows, paths are more unix like with forward slash. and lineendiings LF, but it is still windows so there has to be the option to switch these and for all library code that utilize them.

do they really have to be a constant?
they being EOL, SLASH, PATHSEP ETC.

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

8. Re: SLASH should not be a builtin or constant

ne1uno said...

should be a user environment defined thing, not a constant.

do 'EOL, SLASH, PATHSEP ETC.' really have to be a constant?

Yes they do. User of the library need to know that a third-party library hasn't altered these from the usual values.

If you need to use a different value for your application, then it would be best to define an application specific symbol.

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

9. Re: SLASH should not be a builtin or constant

I don't agree with Derek. Granted, I wouldn't want to encourage the use of global variables in any libs.

If the scope and meaning of such constants were only relevant to the end-code, then this would not be an issue, but there is many third party libs that should also be affected by a platform_override() *HINT*.

How do you tell a 3rd party lib that it is supposed to use your application defined values?

Am I missing something simple?

Chris Bensler The difference between ordinary and extraordinary is that little extra.

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

10. Re: SLASH should not be a builtin or constant

scooby said...

I don't agree with Derek. Granted, I wouldn't want to encourage the use of global variables in any libs.

I don't think that there are any global symbols in the standard library in 4.0. I believe that they're all public.

scooby said...

If the scope and meaning of such constants were only relevant to the end-code, then this would not be an issue, but there is many third party libs that should also be affected by a platform_override() *HINT*.

I guess the hint is too subtle for me. What would platform_override() do?

scooby said...

How do you tell a 3rd party lib that it is supposed to use your application defined values?

If the 3rd party code is supposed to use application defined values, then it should have an API for doing so. I don't think you should try to pull the rug out from under a library by redefining things like the standard library, unless you're willing to go into the library and edit the code if anything breaks.

The point of the standard library is that it is standard, so if you decide to use it, you know what to expect.

Matt

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

11. Re: SLASH should not be a builtin or constant

mattlewis said...

I don't think that there are any global symbols in the standard library in 4.0. I believe that they're all public.

This is just a semantic difference isn't it? Will a global override a public or export symbol?

mattlewis said...

I guess the hint is too subtle for me. What would platform_override() do?

It would allow an application to define a specific platform behaviour. It would change all relevant values (SLASH, EOL, etc) to match the defined platform so a user doesn't have to manually change each of the standard defined, platform specific vars and functions manually. It's use could be restricted to once only per app, possibly by passing a param to the function. Eg. platform_override(LINUX,TRUE) set platform behaviour to linux conventions and allow multiple overrides

If any call to platform_override() passes FALSE, the call will fail if the function has already been previously called. Conversely, any proceeding calls to platform_override() will automatically fail regardless of what params are passed.

Ideally, the constants should be changed to local vars with global interfaces IMO. It would eliminate the possibility of the values being altered unless they use platform_override(). Though I'm not keen on SLASH() and EOL(), etc.

Just a thought anyway.

mattlewis said...

If the 3rd party code is supposed to use application defined values, then it should have an API for doing so. I don't think you should try to pull the rug out from under a library by redefining things like the standard library, unless you're willing to go into the library and edit the code if anything breaks.

The point of the standard library is that it is standard, so if you decide to use it, you know what to expect.

Matt

You suggest that it should be convention for every lib that makes use of any platform specific constants should also define some sort of init() routine to be able to control the behaviour of SLASH, etc? If they don't then the lib is not generic.

Wouldn't it be much simpler for everyone to just accept that such definitions are variable? I would rather learn once that SLASH could be changed, than learn 100 times that a lib must be explicitly overrided by using some_init_function(), not to mention the potentially repetitive code to make it happen and hoping that you did not overlook any libs.

I can imagine that people (albiet few will need to) will just end up resorting to copying and modifying the standard lib to suit their app's need, since we can't ensure that every API developer is going to design with the possibility of alternate platform behaviour.

Chris Bensler Code is Alchemy

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

12. Re: SLASH should not be a builtin or constant

scooby said...
mattlewis said...

I don't think that there are any global symbols in the standard library in 4.0. I believe that they're all public.

This is just a semantic difference isn't it? Will a global override a public or export symbol?

No, it's more than semantics, since it's a different scope. Basically, it's a more limited scope than global. So only files that include the file where it is defined (or that take advantage of public include) will be able to use it. It's not terribly relevant to the issue we're talking about here, but it is an important distinction.

scooby said...
mattlewis said...

What would platform_override() do?

It would allow an application to define a specific platform behaviour. It would change all relevant values (SLASH, EOL, etc) to match the defined platform so a user doesn't have to manually change each of the standard defined, platform specific vars and functions manually. It's use could be restricted to once only per app, possibly by passing a param to the function. Eg. platform_override(LINUX,TRUE) set platform behaviour to linux conventions and allow multiple overrides

Ah, ok. We have this using:

without define LINUX 
with define OSX 
scooby said...

You suggest that it should be convention for every lib that makes use of any platform specific constants should also define some sort of init() routine to be able to control the behaviour of SLASH, etc? If they don't then the lib is not generic.

Actually, what I'm suggesting is a more general principle, which is that you risk breaking 3rd party code if you alter things that it depends upon. It might use some of those constants in ways other than the obvious.

scooby said...

Wouldn't it be much simpler for everyone to just accept that such definitions are variable? I would rather learn once that SLASH could be changed, than learn 100 times that a lib must be explicitly overrided by using some_init_function(), not to mention the potentially repetitive code to make it happen and hoping that you did not overlook any libs.

I think that there are some things where this is worthwhile, but I disagree that the constants were currently discussing fall into that category. You're free to use any definition you like, but I think that for these, there are good reasons for them to be the values that they are, and for the coder to be able to make assumptions about them.

If any piece of code could change the value of SLASH, for example, then any user of that variable would have to test it to make sure it was the value that he needed. Which either renders it pretty useless, or makes combining 3rd party libraries needlessly dangerous, and perhaps impossible. If you want to use a non-standard value, don't use the standard library.

scooby said...

I can imagine that people (albiet few will need to) will just end up resorting to copying and modifying the standard lib to suit their app's need, since we can't ensure that every API developer is going to design with the possibility of alternate platform behaviour.

Yep, I'm sure there will be some, as there always are. It's impossible to please everyone, but I think the standard library has really grown in some very important and beneficial ways, and I think it will be more useful to more people than it was before.

Matt

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

13. Re: SLASH should not be a builtin or constant

scooby said...

How do you tell a 3rd party lib that it is supposed to use your application defined values?

Ok, let's suppose your code (in a library or application) changes the value of SLASH. The how does one tell a 3rd party library not to use the standard defined values? In other words, you can't assume that the standard value of SLASH is not assumed by another library; it depends on the standard value being standard.

This is especially so of the standard library itself. It has a number of routines that depend on SLASH, for instance, containing the correct value in it. If you change that, it is almost certain that you will break some standard library routines.

However, I do understand your issue - if you want 3rd party libraries to use your values instead of the standard ones, how does one do that? But maybe you should be also thinking about whether that is always desirable as it will have consequences that you might not be aware of.

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

14. Re: SLASH should not be a builtin or constant

DerekParnell said...
scooby said...

How do you tell a 3rd party lib that it is supposed to use your application defined values?

Ok, let's suppose your code (in a library or application) changes the value of SLASH. The how does one tell a 3rd party library not to use the standard defined values? In other words, you can't assume that the standard value of SLASH is not assumed by another library; it depends on the standard value being standard.

This is especially so of the standard library itself. It has a number of routines that depend on SLASH, for instance, containing the correct value in it. If you change that, it is almost certain that you will break some standard library routines.

However, I do understand your issue - if you want 3rd party libraries to use your values instead of the standard ones, how does one do that? But maybe you should be also thinking about whether that is always desirable as it will have consequences that you might not be aware of.

Another problem is what would happen if a user may wish to
use more than one 3rd party library then what would you do ?

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

15. Re: SLASH should not be a builtin or constant

mattlewis said...
scooby said...

It would allow an application to define a specific platform behaviour. It would change all relevant values (SLASH, EOL, etc) to match the defined platform so a user doesn't have to manually change each of the standard defined, platform specific vars and functions manually. It's use could be restricted to once only per app, possibly by passing a param to the function. Eg. platform_override(LINUX,TRUE) set platform behaviour to linux conventions and allow multiple overrides

Ah, ok. We have this using:

without define LINUX 
with define OSX 

Good, I think that solves most of the issue in itself. The only other point I could think of that this would not cover is if the platform definition might need to be changed at runtime, but I can't think of any circumstances where this might be needed, so it's moot.

I'd like to comment on some of the other points you made but, I digress. It's a religiuos debate. I'll spare everyone :)

mattlewis said...

Yep, I'm sure there will be some, as there always are. It's impossible to please everyone, but I think the standard library has really grown in some very important and beneficial ways, and I think it will be more useful to more people than it was before.

Certainly they are more useful now, kudos guys. I can almost do away with my empire std libs, since nearly everything has been incorporated now.

Chris Bensler Crunching numbers, one byte at a time.

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

16. Re: SLASH should not be a builtin or constant

scooby said...

I can almost do away with my empire std libs, since nearly everything has been incorporated now.

Damn! What did we miss? blink

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

17. Re: SLASH should not be a builtin or constant

scooby said...

I'd like to comment on some of the other points you made but, I digress. It's a religiuos debate. I'll spare everyone :)

We do that on the dev list. smile

Matt

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

18. Re: std libs (Was: SLASH should not be a builtin or constant)

DerekParnell said...
scooby said...

I can almost do away with my empire std libs, since nearly everything has been incorporated now.

Damn! What did we miss? blink

error.e! :) - fatal_error(), abort_error(), error(), errorf(), set_error_routine(), get_error_routine() - pseudo exception handling throw, catch, drop, fetch, trap...

structs.e - eu is in dire need of a better C/ interface. This would greatly increase the productivity and more importantly, standardization of porting external API's. Whether the average programmer will be dealing with C interfaces directly is not important. What is, is that there is a wealth of API's available in other languages, which eu programmers need to be able to easily access. Someone needs be able to port them and optimally, we don't want to have to redocument everything either, which is the biggest chore. So we need to be able to create ports which represent the original API as accurately as possible, excusing differences between language syntax.

Chris Bensler Foo - The Programmers 'F' word

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

19. Re: std libs (Was: SLASH should not be a builtin or constant)

scooby said...

error.e! :)
- fatal_error(), abort_error(), error(), errorf(), set_error_routine(), get_error_routine()
- pseudo exception handling throw, catch, drop, fetch, trap...

I'm pretty sure that a better exception handling method is being deferred until v4.1. We recognize the need for it, but v4.0 has already made plenty of work for us, and we need to get exceptions right, so let's not rush into it.

scooby said...

structs.e
- eu is in dire need of a better C/ interface.

No argument there either. This is also not something that can be done lightly as it has a lot of performance issues as well, depending on how its implemented.

In my opinion, once v4.0 is bedded down, we - the Euphoria community - can seriously begin addressing these and other significant changes.

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

20. Re: std libs (Was: SLASH should not be a builtin or constant)

scooby said...

error.e! :) - fatal_error(), abort_error(), error(), errorf(), set_error_routine(), get_error_routine()

We have crash()which is, or will be, a built-in routine. What is the difference between fatal_error() abort_error(), error() and errorf()?

We have crash_routine(), which seems to be the same as set_error_routine(). We don't have the get side of that. Would that really be useful?

scooby said...

- pseudo exception handling throw, catch, drop, fetch, trap...

What would you imagine the exception handling [in a library] doing? It seems to me that to be useful, we'd need to have exception handling built into the language itself.

scooby said...

structs.e - eu is in dire need of a better C/ interface. This would greatly increase the productivity and more importantly, standardization of porting external API's. Whether the average programmer will be dealing with C interfaces directly is not important. What is, is that there is a wealth of API's available in other languages, which eu programmers need to be able to easily access. Someone needs be able to port them and optimally, we don't want to have to redocument everything either, which is the biggest chore. So we need to be able to create ports which represent the original API as accurately as possible, excusing differences between language syntax.

Yeah, this would be a really good thinga standard structure library. There are a few out there. My favorite has always been the one that David Cuny developed for Win32Lib. Let the fighting begin!

Anything that uses a C-like interface is easy to interface with, and we've already got the tools for doing so. Languages like C are more difficult, and are not a problem that we're going to solve.

Matt

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

21. Re: std libs (Was: SLASH should not be a builtin or constant)

mattlewis said...
scooby said...

structs.e - eu is in dire need of a better C/ interface. This would greatly increase the productivity and more importantly, standardization of porting external API's. Whether the average programmer will be dealing with C interfaces directly is not important. What is, is that there is a wealth of API's available in other languages, which eu programmers need to be able to easily access. Someone needs be able to port them and optimally, we don't want to have to redocument everything either, which is the biggest chore. So we need to be able to create ports which represent the original API as accurately as possible, excusing differences between language syntax.

Yeah, this would be a really good thinga standard structure library. There are a few out there. My favorite has always been the one that David Cuny developed for Win32Lib. Let the fighting begin!

Anything that uses a C-like interface is easy to interface with, and we've already got the tools for doing so. Languages like C are more difficult, and are not a problem that we're going to solve.

Matt

Adding the ability to directly pass C structures (not pointers to structures, but the structure itself, on the stack, using native C calling conventions) would be a bonus too.

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

22. Re: std libs (Was: SLASH should not be a builtin or constant)

mattlewis said...
scooby said...

error.e! :) - fatal_error(), abort_error(), error(), errorf(), set_error_routine(), get_error_routine()

We have crash()which is, or will be, a built-in routine. What is the difference between fatal_error() abort_error(), error() and errorf()?

All of the mentioned routines accept a string msg and are descriptive. fatal_error(msg) will call crash_message(msg) before crashing abort_error(code,msg) will echo msg to stderr, prompt user for key press then abort gracefully with code error(msg,args) will call the user-defined error routine errorf(msg,args) calls error() passing sprintf(msg,args) as msg, I should have omitted this, it has issues

mattlewis said...

We have crash_routine(), which seems to be the same as set_error_routine(). We don't have the get side of that. Would that really be useful?

get and set allow for multiple error routines to be stacked and called recursively. So one lib can safely redefine the error() function and have the new handler call the old error handler that may have been set by another lib, or choose to override. A stack would be better.

mattlewis said...
scooby said...

- pseudo exception handling throw, catch, drop, fetch, trap...

What would you imagine the exception handling [in a library] doing? It seems to me that to be useful, we'd need to have exception handling built into the language itself.

I should have described it as error trapping instead. There is no way for a library implementation to offer the same level of automation and cleanliness as builtin syntax. There is no elegant way to unwind the stack.

Here is a short description from the comments of the lib: These routines make it possible to throw an error from one routine, back through the call stack,

where they can be trapped and handled automatically, using the defined error handler, or they can be caught and handled on demand at the program level.

The lib can be configured so that thrown errors act immediately, like any other error. It can also be configured so that if multiple errors are thrown, they will trigger a cascade. Or multiple errors can be put on the pending stack, to be handled later at the callers discretion.

Short example: allow_error_trapping(TRUE) not scope specific :( allow_pending_errors(TRUE) "" ""

global constant ERROR_FSEEK = define_error(NULL) use the deault error handler ( error() ) global procedure fseek(file_num fn, file_pos pos) if machine_func(M_SEEK, {fn, pos}) then throw_error(ERROR_FSEEK,"seek error") stack the error handler until it is trapped end if end procedure

Called from: fseek(fn,pos)

Called from: etc... if drop_error(ERROR_FSEEK) then - don't care, discard close(fn) we're done end if trap_error(NULL) catch any remaining errors

Chris Bensler

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

Search



Quick Links

User menu

Not signed in.

Misc Menu