Zephir code DIRECTORY_SEPARATOR. WHY??

Why use DIRECTORY_SEPARATOR for winOS compatibility? After all, on winOS always work on both \ and /. We want use only convert from Win to Unix, but not Unix from Win

<?php
    public function setViewsDir(var viewsDir) 
    {
        var position, directory, directorySeparator, newViewsDir;

        if typeof viewsDir != "string" && typeof viewsDir != "array" {
            throw new Exception("Views directory must be a string or an array");
        }
      // we want only revert from WIN to UNIX
        let directorySeparator = DIRECTORY_SEPARATOR;
        if typeof viewsDir == "string" {

            if substr(viewsDir, -1) != directorySeparator {
                let viewsDir = viewsDir . directorySeparator;
            }

            let this->_viewsDirs = viewsDir;
        } else {

            let newViewsDir = [];
            for position, directory in viewsDir {

                if typeof directory != "string" {
                    throw new Exception("Views directory item must be a string");
                }

                if substr(directory, -1) != directorySeparator {
                    let newViewsDir[position] = directory . directorySeparator;
                } else {
                    let newViewsDir[position] = directory;
                }
            }

            let this->_viewsDirs = newViewsDir;
        }

        return this;
    }
?>

DIRECTORY_SEPARATOR is OLD like PHP3

edited Mar '19

You are asking for a Windows change that reverses an old behavior. This change would cut tens of millions of applications that have been written in that time that need to use backslashes, decide strings with backslashes, and use API's that only admit backslashes. How would Windows know if an application really wanted a forward slash or backslash, particularly on a console app? Not to discuss several billion windows users would more need to modify their own behavior.



1.1k

You are asking for a Windows change that reverses an old behavior. This change would cut tens of millions of applications that have been written in that time that need to use backslashes, decide strings with backslashes, and use API's that only admit backslashes. How would Windows know if an application really wanted a forward slash or backslash, particularly on a console app? Not to discuss several billion windows users would more need to modify their own behavior.

I'm talking about integrity, so what about millions and mine?

<?php
//Why not DIRECTORY_SEPARATOR ?
let renderView = controllerName. "/". actionName; 
edited Mar '19

Why use DIRECTORY_SEPARATOR for winOS compatibility? After all, on winOS always work on both \ and /.

Windows may, but 3rd party apps may not.

Unix and Win are not the only OSs out there, in theory one could use other characters than / and \ for directory separation.

Using the constant DIRECTORY_SEPARATOR is robust, you can reason about it easily when comprehending the source code.