Why, for example, maps but array?

Lloyd R. Prentice lloyd@REDACTED
Sun Aug 15 16:30:21 CEST 2021


Ah, thank you, Łukasz,

Got it.

All the best,

LRP

Sent from my iPad

> On Aug 15, 2021, at 5:21 AM, Łukasz Niemier <lukasz@REDACTED> wrote:
> 
> 
>> 
>> But it surprises me that obvious functions like file:move/2
> 
> The problem is that such function is far from "obvious". If you look through many languages you will see, that rarely there is `move` function that moves the file from one location to another. Reason for that is simple - UNIX (I do not know how about Windows) do not have such function, instead there is `rename` function which indeed is present in Erlang [1]. That function has one great limitation - it works **only within single filesystem**. If you want to move file between different filesystems, then it will fail.
> 
> - But, there is `mv` command in shell.
> 
> You may ask. Yes, there is such command, but it operates in 2 different ways, depending on the locations of the files:
> 
> - If source and destination is on the same filesystem, then it just call `rename` and call it a day.
> - If source and destination is on different filesystems, then it reads source file, writes it in the destination (aka, does a copy of that file) and then removes the source.
> 
> So reasons for non-existence of `file:move/2` in Erlang is law of leaky abstractions. Nothing more, nothing less.
> 
> [1]: https://erlang.org/doc/man/file.html#rename-2
> 
> --
> 
> Łukasz Niemier
> lukasz@REDACTED
> 



More information about the erlang-questions mailing list