cd in Shen/Scheme and Shen/SBCL

99 views
Skip to first unread message

dr.mt...@gmail.com

unread,
May 27, 2024, 9:23:22 AMMay 27
to Shen
I'm now testing Shen/tk under both Shen/SBCL and Shen/Scheme
and they both work fine with no code changes other than path
names.  This is exactly what I wanted.  But there is a detail
which didn't work and it seems to involve cd in Shen.  This
uses absolute path names to set the home directory.

cd changes the working directory.  It doesn't work
the same in Shen/SBCL and Shen/Scheme.

Shen/SBCL

(0-) (cd "StLib")   \\ change the working directory to StLib
"StLib/"

(1-)  (cd "Tk")  \\ now change it to Tk
"Tk/"

That's pretty straight.

Shen/Scheme

(0-) (cd "StLib")
"C:\Users\shend\OneDrive\Desktop\Shen\Shen-Scheme\shen-scheme-v0.36-windows-bin\bin\StLib"

(1-) (cd "Tk")
"C:\Users\shend\OneDrive\Desktop\Shen\Shen-Scheme\shen-scheme-v0.36-windows-bin\bin\StLib\Tk"

You see that cd seems to cd relative to the last command under Scheme and not under SBCL.   I looked at the sources in ShenOSKernel-38.3 and the source code is the same.

(define cd
  Path -> (set *home-directory* (if (= Path "") "" (make-string "~A/" Path))))

So I'm a bit foxed here.  Other than this all seems good.

I looked at what TBOS said and this is what it says in a footnote.

The behaviour is partly dependent on platform and the operating system .

I think we need to straighten this out for the sake of portability.

Mark


Bruno Deferrari

unread,
May 27, 2024, 10:59:52 AMMay 27
to qil...@googlegroups.com
in Shen/Scheme `cd` is overridden so that the native Chez implementation is used. With that any Scheme code that does I/O remains in sync too (and the other way around too):

(define cd
"" -> (cd (value shen.*initial-home-directory*))
Dir -> (let NewDir ((foreign scm.current-directory) Dir)
(set *home-directory* ((foreign scm.current-directory)))))


It also supports some extensions like ".." and "~":

(0-) (cd "..")

"/Users/bruno/projects/shen"


(1-) (cd "..")

"/Users/bruno/projects"


(2-) (cd "~")

"/Users/bruno"


But I'm ok with any version (a differently named function could be provided in Shen/Scheme that behaves like this). I have a slight preference to a relative `cd` because it matches how `cd` works in the shell (which is relative to the last directory, and when no param is given, it returns the user to the initial directory).
--
You received this message because you are subscribed to the Google Groups "Shen" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qilang+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/qilang/1b5045cf-b153-4415-a18f-dbe55cbca057n%40googlegroups.com.


--
BD

dr.mt...@gmail.com

unread,
May 27, 2024, 3:51:40 PMMay 27
to Shen
I think I'd rather stick with the default version in Shen/SBCL which is simple
and requires no kernel changes or rewriting TBoS and probably is what the 
other ports run on.

I think there's no harm in having your cd under a different title (scm.cd?) linked 
to Scheme.  If you implement it in Shen then it could be a standard library function.

I'll put a work-around plaster on the Shen/tk installation which will allow the
system to be loaded for both SBCL and Shen.  

Mark

Mark Tarver

unread,
May 27, 2024, 5:28:56 PMMay 27
to qil...@googlegroups.com
SBCL and Scheme 

M.

dr.mt...@gmail.com

unread,
May 29, 2024, 12:59:06 AMMay 29
to Shen
Another way of dealing with this is to put a flag into your code which 
toggles between Shen cd and that defined by Scheme and make the
default the Shen cd.  That conserves consistency w.o. sacrifice.

M.

Bruno Deferrari

unread,
May 29, 2024, 12:27:27 PMMay 29
to qil...@googlegroups.com
No need, I don't think anyone is depending on `cd` behaving like that in Shen/Scheme. I will publish a new release sometime this week with that change.
 

M.

--
You received this message because you are subscribed to the Google Groups "Shen" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qilang+un...@googlegroups.com.

Bruno Deferrari

unread,
Jun 2, 2024, 11:12:47 AMJun 2
to qil...@googlegroups.com
Just released v0.38 which doesn't override `cd`.

https://github.com/tizoc/shen-scheme/releases/tag/v0.38
--
BD

Mark Tarver

unread,
Jun 3, 2024, 5:32:00 AMJun 3
to qil...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages