Re: Absolute path of source file

Zelphir Kaltstahl <[email protected]>
Newsgroups gmane.lisp.guile.user
Message-ID <[email protected]>
Hello reza!

On 23.09.24 17:47, reza wrote:
> Hi Retropikzel
>
> Perfect, works out of the box!
> I missed this part in the manual, just saw that it is in chapter "Source
> Properties" where I would never have guessed to look at.
> Thanks very much,
> Reza
>
>> On Mon, 23 Sep 2024 15:35:03 +0000
>> reza<[email protected]>  wrote:
>>
>>> Hi List
>>>
>>> How can I get the absolute path to a source file from itself. In bash
>>> this would look like something along the lines
>>>
>>>      realpath $(dirname $0)
>>>
>>> but I could not figure out how to achieve this in guile.
>>>
>>> Thanks for any hints!
>>> Cheers,
>>> Reza
>>>
>> Hi! Might example from here:
>> https://www.gnu.org/software/guile/manual/guile.html#Load-Paths-1
>>
>> work?
>>
>>      (dirname (current-filename))

I just want to add, that in most cases you can probably make things work using 
the `guile -L` argument and naming the files of guile modules according to the 
module defined in them. It has been a long time, since I had to reach for 
something like `(dirname (current-filename))`. Of course there might be cases, 
where you want to have that directory as a string in your code or so. I am only 
writing this, because it is often brought up in a context of adding things to 
the load path, where it should not be necessary.

For example see: 
https://codeberg.org/ZelphirKaltstahl/guile-algorithms/src/commit/97f29e9a9414bd068e9b6e0745a768ad64a10dac/readme.md. 
And if that is too much of a hassle, you could create a makefile, that runs 
either the program or a guile shell that has the directories added to the load 
path. Something like 
https://codeberg.org/ZelphirKaltstahl/guile-algorithms/src/commit/97f29e9a9414bd068e9b6e0745a768ad64a10dac/graphs/Makefile.

Best regards, Zelphir

-- 
repositories:https://notabug.org/ZelphirKaltstahl,https://codeberg.org/ZelphirKaltstahl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.