Giter Club home page Giter Club logo

ironscheme's Introduction

IronScheme

IronScheme aims to be a R6RS conforming Scheme-like implementation for all .NET implementations and platforms.

IronScheme implements over 99% of the R6RS specification and specified behavior.

IronScheme's macro system is based on psyntax, and thus behaves similar to other implementations using psyntax, ie Icarus, Vicare, Chez.

Build status

Building

  1. Open the IronSchemeCore.sln file in VS2019/2022
  2. Set startup project as IronScheme.Console

Alternatively, using the build.cmd batchfile in the IronScheme directory.

Note: the VS solution is for an already bootstrapped configuration. It can behave differently to the IronScheme.dll in the release package. This is mostly to just provide debugging and advanced usage of IronScheme.

Running on Windows

Run the IronScheme.Console.exe for the runtime and bitness you want to target.

V2 requires .NET3.5. V4 requires requires .NET4.0 or higher. Pretty much any running Windows should have one or both of those.

You can also run it with .NET Core, which has no persisted compilation functionality. It may load precompiled libraries, but if it fails to load, it will fallback to runtime compilation. A warning will be display in that case.

By default, it will run on the lowest supported .NET Core runtime installed.

To Run it on a specific .NET Core version, use the --fx-version option with dotnet.

Example to run on .NET 6.0 when you have multiple framework versions installed:

dotnet --fx-version 6.0.0 IronScheme.ConsoleCore.dll <args...>

or

IronScheme.ConsoleCore.exe --fx-version 6.0.0 <args...>

To run on the latest installed .NET Core version:

IronScheme.ConsoleCore.exe --roll-forward LatestMajor <args...>

Running on Linux/MacOS

The preferred way to run on non-Windows OS is to use .NET Core. You can also run IronScheme on Mono, but your mileage may vary.

# get .NET Core if you dont have it already
wget https://dot.net/v1/dotnet-install.sh
chmod +x dotnet-install.sh
dotnet-install.sh --channel Current --runtime dotnet # v2.1+
export -p PATH="$HOME/.dotnet:$PATH"
# Download 
wget https://github.com/IronScheme/IronScheme/releases/download/<latest release>.zip
unzip <latest release>.zip
cd IronScheme
alias ironscheme="dotnet IronScheme.ConsoleCore.dll"
# if you prefer Mono
# alias ironscheme="mono IronScheme.Console-v4.exe"

ironscheme

Library usage

Reference IronScheme.dll from your project.

using IronScheme;

class Program
{
    static void Main(string[] args)
    {
        "(display 'hello-world)".Eval();
    }
} 

Or with C# 9 and later as:

using IronScheme;

"(display 'hello-world)".Eval();

Running tests

To run the R6RS test suite, call the (ironscheme-test) procedure. There are a few known failure cases (currently 3 for .NET desktop). This can be run from the release package as well to confirm IronScheme runs correctly on a new platform or framework.

After building, you can use NUnit to run IronScheme.Tests.dll in the IronScheme.Console bin folder.

There is also a batch file in the IronScheme directory called test.cmd. You can pass the /verbose to the batch file to see complete output in case of failures.

Note

Make sure that peverify is in your PATH. The test fixtures are designed to execute in a specfic order. The tests will not take less than 6 minutes to complete.

Nuget feed

On Nuget.org and CI-builds on https://ci.appveyor.com/nuget/ironscheme

Issues/PR

Please @leppie in your issues/PR's, else I will probably not know about it. I do not actively monitor Github. If I still dont answer, nag me on Twitter, also @leppie.

ironscheme's People

Contributors

kant2002 avatar leppie avatar mwalser avatar simendsjo avatar weinholt avatar zambito1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ironscheme's Issues

Stop binary search

In the console, when there's an error, at least tell which line the error occurred, so people like me can stop doing "commenting binary search" to find where the error is (i.e. comment half the code, and keep going until there's no errors).

Unhandled exception during evaluation:
&lexical
&message: "invalid syntax"
&irritants: (#<binary-input-port>)

Building/upgrading to VS 2017

I am trying to upgrade using VS 2017 (15.9.9).

.NET Framework version 4.7.0356.

IronScheme.zip

Switched to Release. Build both .sln files gave such errors:

Metadata file IronScheme.dll not found for IronScheme.Remoting.Server, IronScheme.Web.Runtime;
Metadata file IronScheme.Remoting.Server.dll, IronScheme.Web.Runtime.dll not found for IronScheme.Console
The command "attrib -R "C:\Users\Администратор\Desktop\IronScheme-master\IronScheme\IronScheme\Compiler\IronScheme.y.cs"
attrib -R "C:\Users\Администратор\Desktop\IronScheme-master\IronScheme\IronScheme\Compiler\IronScheme.lex.cs"
"C:\Users\Администратор\Desktop\IronScheme-master\IronScheme\tools\gppg" /gplex "C:\Users\Администратор\Desktop\IronScheme-master\IronScheme\IronScheme\Compiler\IronScheme.y" > "C:\Users\Администратор\Desktop\IronScheme-master\IronScheme\IronScheme\Compiler\IronScheme.y.cs"
"C:\Users\Администратор\Desktop\IronScheme-master\IronScheme\tools\gplex" /stack "/out:C:\Users\Администратор\Desktop\IronScheme-master\IronScheme\IronScheme\Compiler\IronScheme.lex.cs" "C:\Users\Администратор\Desktop\IronScheme-master\IronScheme\IronScheme\Compiler\IronScheme.lex"
"C:\Users\Администратор\Desktop\IronScheme-master\IronScheme\tools\gppg" /gplex "C:\Users\Администратор\Desktop\IronScheme-master\IronScheme\IronScheme\Compiler\NumberParser.y" > "C:\Users\Администратор\Desktop\IronScheme-master\IronScheme\IronScheme\Compiler\NumberParser.y.cs"
"C:\Users\Администратор\Desktop\IronScheme-master\IronScheme\tools\gplex" /stack "/out:C:\Users\Администратор\Desktop\IronScheme-master\IronScheme\IronScheme\Compiler\NumberLexer.lex.cs" "C:\Users\Администратор\Desktop\IronScheme-master\IronScheme\IronScheme\Compiler\NumberLexer.lex"" exited with code 3.

Are PCL profiles supported?

I'm not sure if you can use the DLR in PCL libraries (profiles 158 & 78 are what I'm using). Do you know if it's possible?

If not, I can do the research and update this issue as necessary, possibly doing a PR to add support.

Scheme

Hi,

I want to solve this exercise http://acm.up.pt/local/Historial/2002/s2_c.htm

and this is my code so far,

lang racket

(require racket/block)

(define (print_ls ls)
(if (empty? ls)
(display "")
(block
(print_code (car ls) 0 1)
(displayln "")
(print_ls (cdr ls)))))

(define (print_code ls tab per)
(if (pair? ls)
(let ([ln (length ls)])
(cond
(equal? ln 2) (if (equal? per 1)
(block
(print_tab (+ tab 1))
(displayin ""))
(block
(print_tab tab)
(displayln (caddr ls))))
(if (pair? (caddr ls))
(print_code (caddr ls) tab 1)
(block
(print_tab tab)
(display (caddr ls))))
(display ")")))))

What is the missing to make the code running?

Thanks

Possible bug of equal? implementation

When I run the test suite of my R6RS Scheme project some test cases fail, although I know other R6RS systems pass (Racket, Larceny, Petite Chez Scheme). GNU Guile fails the same test cases because of a non-R6RS compliant equal? implementation. For this reason, I assume that IronScheme might have a similar problem with equal?.

Short background: My RACR project is a language processor library based on reference attribute grammar controlled rewriting. One of the example languages is a Petri net interpreter supporting the composition of nets in execution. The composition is based on place fusion. Place fusion requires fixpoint semantics to find all places a place is fused with (transitive closure computation). I therefore use circular attributes to compute this reachability problem. Fixpoint semantics require a termination condition. In case of reachability, the computation should terminate when the set of reachable places does not change anymore. In that process I use equal? to compare circularity-caches. The content of these caches are R6RS records, that themselves encode circular data structures. Since equal? must be well-defined for circular data structures according to the R6RS, this is not a problem.

When using IronScheme however, stack overflow exceptions are thrown. I got similar exceptions for GNU Guile, which does not support equality tests on circular data structures.

Does IronScheme support equal? on circular data structures? I use Mono in OS X. Maybe its a Mono issue?

Odd symbol comparison behaviour

I've come across this behaviour which wasn't quite what I expected. Is it an actual bug or am I missing something?

Console.WriteLine("(eq? 'A 'A)".Eval());                                        // True
Console.WriteLine("(eq? 'A {0})".Eval("'A".Eval()));                            // True
Console.WriteLine("(eq? 'A {0})".Eval((SymbolId) "'A".Eval()));                 // False
Console.WriteLine("(eq? 'A {0})".Eval((SymbolId) "A"));                         // False
Console.WriteLine("(eq? {0} {1})".Eval((SymbolId) "A", (SymbolId) "A"));        // False
Console.WriteLine("eq?".Eval<Callable>().Call((SymbolId) "A", (SymbolId) "A")); // False

Reader does not recognize \a, \b, \v, \f

The reader is missing support for some of the ASCII control character escapes, namely \a, \b, \v and \f.

IronScheme 1.0.182-8632bda github.com/leppie/IronScheme © 2007-2019 Llewellyn Pritchard (.NET 4.0 64-bit)
> (string-length "\a\b\v\f")        
8

The expected output is 4.

I checked your lexer and it very obviously doesn't have this bug. Interesting!

single_string_char     [^\\\"\n\r]
string_esc_seq         (\\[\"\\abfnrtv])

(This is causing the test failure in weinholt/laesare).

.NET Core 2.1 port

Main

  • Single assembly for all platforms (CLR 2, CLR 4, CLR 4.5, Core 2.0)?
  • Create compat stubs (decide between reflection delegates or platform assembly)
  • Debugging options
  • Remove useless shit

Compat stubs

  • AppDomain.CreateDynamicAssembly
  • AssemblyBuilder methods
  • ModuleBuilder methods

Useless shit

  • Remoting

.NET Core support TODO's

  • Tests (this runs, just need to add to CI)
  • Docs for running on .NET Core
  • Compiled library loading support (this goes wrong somewhere...)

Whitespace in character literals

I have some failing test cases that I suspect are caused by how the IronScheme reader treats #\ followed by a tab or a newline. It turns them into #\space I think. If my reading (no pun intended) of R6RS is correct, it should preserve the tab or newline.

Admittedly, using raw tabs or newlines in character literals is pretty terrible practice, but I suppose the standard says it should work anyway. I auto-convert some code from R7RS to R6RS, that's why they end up in there...

Improve inlining/TCE with closures

See the generated code equal-hash. Normally the code would be inlined/TCE, but due to environment, does not, but free variable would be eliminated when inlined/TCE.

Up-to-date installer?

@leppie The Code Project article Playing with IronScheme has a screenshot of a setup program for IronScheme. Is such a setup still available for the latest version, or does IronScheme need to be incorporated into a Visual Studio project?

.NET Core 3.0 port

It's 2019 now. I wonder if there any understanding/vision on porting the project to .NET Core 3.0.

IronScheme shell command name

Quoting @leppie from https://github.com/weinholt/scheme-docker/issues/3:

If you create a symlink to the exe called isc it should not print [the logo]. Not sure if this works on Linux though. I will remove the logo if a file has been passed in.

Is isc the preferred shell command name for IronScheme? We didn't know this so the current IronScheme wrapper in the Docker container is named ironscheme.

There's a tradition of using 3-4 letter commands for Scheme interpreters and compilers, but such short names are somewhat problematic since name clashes are to be expected eventually. Gambit's gsc as well as Chicken's csc and csi already conflict with other non-Scheme software. Based on that precedent, I would recommend just sticking with ironscheme which is self-explanatory and bound not to conflict with any other program. Most shells have tab completion for commands nowadays so it's not that much to type.

UTF-8 in source code with Mono

Hello @leppie! I have a bunch of source code where the files are encoded in UTF-8. I can't seem to get IronScheme to read them with the right encoding; they appear to be read as iso-8859-1:

# export LANG=C.UTF-8
# cat foo.scm
(import (rnrs))
(display "åäö\n")
# mono /usr/local/IronScheme/IronScheme.Console-v4.exe foo.scm
IronScheme 1.0.110-6a2cd45 github.com/leppie/IronScheme © 2007-2016 Llewellyn Pritchard (.NET 4.0 64-bit)
åäö

This is with Mono 5.18.0.240+dfsg-3 on Debian 10.0 (amd64). The exact environment is available in Docker as weinholt/ironscheme:latest.

Any suggestions?

Hashtables don't accept empty list as key.

To my understanding this programme conforms with r6rs and it runs without problems in racket. IronScheme throws an exception.

(import (rnrs))
(hashtable-ref (make-eq-hashtable) '() 'default)

Non-trivial record protocols get a procedure, not an instance

Hello @leppie! When a define-record-type has a non-trivial protocol, it appears that the constructor returns a procedure instead of an instance.

(import (rnrs))

(define-record-type foo
  (fields bar (mutable baz))
  (protocol
   (lambda (p)
     (case-lambda
       ((bar)
        (let ((foo (p bar #f)))
          (foo-baz-set! foo bar)
          foo))))))

(display (foo-bar (make-foo 1)))
(newline)

The program above should print 1, but instead it crashes with an assertion:

&assertion
&message: "expected type: foo"
&irritants: (#<procedure <RecordConstructor>b__2>)

Here is another program that demonstrates the problem:

(import (rnrs))

(define-record-type foo
  (fields bar)
  (protocol
   (lambda (p)
     (case-lambda
       ((bar)
        (validate (p bar)))))))

(define (validate x)
  (write x) (newline)
  (assert (foo? x))
  x)

(display (foo-bar (make-foo 1)))
(newline)

Changing the validate procedure to just return x makes the bug go into hiding.

Found with IronScheme 1.0.121-393d598 (.NET 4.0 64-bit) on Mono 5.18.0.240+dfsg-3.

wak.fmt.c::c-apply

[IL]: Error: [wak.fmt.c::c-apply]
[offset 0x000000FD]
[found value 'IronScheme.Scripting.SymbolId'][expected ref 'System.Object'] 
Unexpected type on the stack.

Odd error

Should not return #!eof when reading zero bytes

The procedures get-bytevector-n, get-string-n, get-bytevector-n! and get-string-n! in IronScheme don't work as expected when count is zero.

All other implementations work the same way. (Except for Loko, which I'll fix). Here are the test results:

; Guile
(get-bytevector-n (open-bytevector-input-port #vu8()) 0) => #vu8()
(get-bytevector-n (open-bytevector-input-port #vu8(1)) 0) => #vu8()
(get-string-n (open-string-input-port "") 0) => ""
(get-string-n (open-string-input-port "x") 0) => ""
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #vu8()) x 0 0)) => 0
(let ((x (make-string 0))) (get-string-n! (open-string-input-port "") x 0 0)) => 0
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #vu8(1)) x 0 0)) => 0
(let ((x (make-string 0))) (get-string-n! (open-string-input-port "x") x 0 0)) => 0

; Vicare
(get-bytevector-n (open-bytevector-input-port #vu8()) 0) => #vu8()
(get-bytevector-n (open-bytevector-input-port #vu8(1)) 0) => #vu8()
(get-string-n (open-string-input-port "") 0) => ""
(get-string-n (open-string-input-port "x") 0) => ""
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #vu8()) x 0 0)) => 0
(let ((x (make-string 0))) (get-string-n! (open-string-input-port "") x 0 0)) => 0
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #vu8(1)) x 0 0)) => 0
(let ((x (make-string 0))) (get-string-n! (open-string-input-port "x") x 0 0)) => 0

; Chez
(get-bytevector-n (open-bytevector-input-port #vu8()) 0) => #vu8()
(get-bytevector-n (open-bytevector-input-port #vu8(1)) 0) => #vu8()
(get-string-n (open-string-input-port "") 0) => ""
(get-string-n (open-string-input-port "x") 0) => ""
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #vu8()) x 0 0)) => 0
(let ((x (make-string 0))) (get-string-n! (open-string-input-port "") x 0 0)) => 0
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #vu8(1)) x 0 0)) => 0
(let ((x (make-string 0))) (get-string-n! (open-string-input-port "x") x 0 0)) => 0

; Larceny
(get-bytevector-n (open-bytevector-input-port #u8()) 0) => #u8()
(get-bytevector-n (open-bytevector-input-port #u8(1)) 0) => #u8()
(get-string-n (open-string-input-port "") 0) => ""
(get-string-n (open-string-input-port "x") 0) => ""
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #u8()) x 0 0)) => 0
(let ((x (make-string 0))) (get-string-n! (open-string-input-port "") x 0 0)) => 0
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #u8(1)) x 0 0)) => 0
(let ((x (make-string 0))) (get-string-n! (open-string-input-port "x") x 0 0)) => 0

; Ikarus
(get-bytevector-n (open-bytevector-input-port #vu8()) 0) => #vu8()
(get-bytevector-n (open-bytevector-input-port #vu8(1)) 0) => #vu8()
(get-string-n (open-string-input-port "") 0) => ""
(get-string-n (open-string-input-port "x") 0) => ""
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #vu8()) x 0 0)) => 0
(let ((x (make-string 0))) (get-string-n! (open-string-input-port "") x 0 0)) => 0
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #vu8(1)) x 0 0)) => 0
(let ((x (make-string 0))) (get-string-n! (open-string-input-port "x") x 0 0)) => 0

; Mosh
(get-bytevector-n (open-bytevector-input-port #vu8()) 0) => #vu8()
(get-bytevector-n (open-bytevector-input-port #vu8(1)) 0) => #vu8()
(get-string-n (open-string-input-port "") 0) => ""
(get-string-n (open-string-input-port "x") 0) => ""
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #vu8()) x 0 0)) => 0
(let ((x (make-string 0))) (get-string-n! (open-string-input-port "") x 0 0)) => 0
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #vu8(1)) x 0 0)) => 0
(let ((x (make-string 0))) (get-string-n! (open-string-input-port "x") x 0 0)) => 0

; Racket
(get-bytevector-n (open-bytevector-input-port #vu8()) 0) => #vu8()
(get-bytevector-n (open-bytevector-input-port #vu8(1)) 0) => #vu8()
(get-string-n (open-string-input-port "") 0) => ""
(get-string-n (open-string-input-port "x") 0) => ""
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #vu8()) x 0 0)) => 0
(let ((x (make-string 0))) (get-string-n! (open-string-input-port "") x 0 0)) => 0
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #vu8(1)) x 0 0)) => 0
(let ((x (make-string 0))) (get-string-n! (open-string-input-port "x") x 0 0)) => 0

; Ypsilon
(get-bytevector-n (open-bytevector-input-port #vu8()) 0) => #vu8()
(get-bytevector-n (open-bytevector-input-port #vu8(1)) 0) => #vu8()
(get-string-n (open-string-input-port "") 0) => ""
(get-string-n (open-string-input-port "x") 0) => ""
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #vu8()) x 0 0)) => 0
(let ((x (make-string 0))) (get-string-n! (open-string-input-port "") x 0 0)) => 0
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #vu8(1)) x 0 0)) => 0
(let ((x (make-string 0))) (get-string-n! (open-string-input-port "x") x 0 0)) => 0

; Sagittarius
(get-bytevector-n (open-bytevector-input-port #vu8()) 0) => #vu8()
(get-bytevector-n (open-bytevector-input-port #vu8(1)) 0) => #vu8()
(get-string-n (open-string-input-port "") 0) => ""
(get-string-n (open-string-input-port "x") 0) => ""
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #vu8()) x 0 0)) => 0
(let ((x (make-string 0))) (get-string-n! (open-string-input-port "") x 0 0)) => 0
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #vu8(1)) x 0 0)) => 0
(let ((x (make-string 0))) (get-string-n! (open-string-input-port "x") x 0 0)) => 0

; Loko (I'll fix this, of course):
(get-bytevector-n (open-bytevector-input-port #vu8()) 0) => #!eof
(get-bytevector-n (open-bytevector-input-port #vu8(1)) 0) => #vu8()
(get-string-n (open-string-input-port "") 0) => ""
(get-string-n (open-string-input-port "x") 0) => ""
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #vu8()) x 0 0)) => An exception has been raised, but no exception handler is installed.
The condition has 4 components:
 1. &error &serious
 2. &who
     who: eval
 3. &message
     message: "This primitive is not yet implemented"
 4. &irritants
     irritants: (get-bytevector-n!)
End of condition components.

; IronScheme
(get-bytevector-n (open-bytevector-input-port #vu8()) 0) => #<eof>
(get-bytevector-n (open-bytevector-input-port #vu8(1)) 0) => #<eof>
(get-string-n (open-string-input-port "") 0) => #<eof>
(get-string-n (open-string-input-port "x") 0) => #<eof>
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #vu8()) x 0 0)) => #<eof>
(let ((x (make-string 0))) (get-string-n! (open-string-input-port "") x 0 0)) => &assertion
(let ((x (make-bytevector 0))) (get-bytevector-n! (open-bytevector-input-port #vu8(1)) x 0 0)) => #<eof>
(let ((x (make-string 0))) (get-string-n! (open-string-input-port "x") x 0 0)) => &assertion

Typed enhancements

  • Generic method definitions
  • Generic type defintions

Both of these are a bit problematic as you can only create the generic type after the type/method builder has been instantiated.

Current idea is to inherit a class from TypeDelegator to save some context info and then after method has been created, I can collect the 'generic' types used and convert them into actual generic types. Have no idea if this will work.

evaluation of continuation fails

Hi
I started to use IronScheme (great stuff by the way, thank you for sharing) to "re-new" my scheme knowhow.
I am trying to understand continuations by reading "The Scheme Programming Language", second edition since my copy of Abelson Sussmann SICP does not seem to discuss that feature.

When I try to execute
(let ((x (call/cc (lambda (k) k)))) ;; x local vars
(x (lambda (ignore) "hi"))) ;; body

I get the following error in IronScheme console and/or the VS plugin:
&assertion
&who: "call/cc"
&message: "not supported, continuation called outside dynamic extent"
&irritants: ()

Gambit and DrRacket (with Scheme language) return the correct result "hi" as described in the first mentioned book on page 62.

transcoded-port relies on port-position/set-port-position!

The get-line procedure behaves strangely with custom binary input ports and also raises a condition.

There are three different types of errors:

  • If both get-position and set-position! are provided then all data is read by the first get-line but the second get-line call crashes.
  • If only get-position is provided then every sixth character is returned in the first get-line, followed by a crash in get-line.
  • If neither position procedure is provided then get-line crashes the first time.

The following program demonstrates the problems:

(import (rnrs))

(define (open-test)
  (define pos 0)
  (define data
    (string->utf8 "    0     1     2     3     4     5"))
  (define (read! bv start count)
    (let* ((bytes-read (fxmin count
                              (fx- (bytevector-length data) pos))))
      (bytevector-copy! data pos bv start bytes-read)
      (write `(bytevector-copy! data ,pos bv ,start ,bytes-read))
      (newline)
      (set! pos (+ pos bytes-read))
      bytes-read))
  (define (get-position) pos)
  ;; (define get-position #f)
  ;; (define (set-position! x) (set! pos x))
  (define set-position! #f)
  (make-custom-binary-input-port "test" read! get-position set-position! #f))

(call-with-port (transcoded-port (open-test) (native-transcoder))
  (lambda (p)
    (let lp ()
      (let ((line (get-line p)))
        (write line)
        (newline)
        (unless (eof-object? line)
          (lp))))))

Example output:

(bytevector-copy! data 0 bv 0 4)
(bytevector-copy! data 4 bv 0 6)
(bytevector-copy! data 10 bv 0 6)
(bytevector-copy! data 16 bv 0 6)
(bytevector-copy! data 22 bv 0 6)
(bytevector-copy! data 28 bv 0 6)
(bytevector-copy! data 34 bv 0 1)
(bytevector-copy! data 35 bv 0 0)
"012345"
(bytevector-copy! data 35 bv 0 0)
&i/o-port: #<textual-input-port>
&who: get-line

(I hope that this access pattern for ports is not the usual one, as it seems quite inefficient).

Tested with IronScheme 1.0.186-31c6aae on Mono 5.18.0.240+dfsg-3 (.NET 4.0 64-bit).

#!eof is ignored

This should signal the reader to stop reading, but it does not.

(import (rnrs))
(display "I am a dick")
(newline)
#!eof
(display "I am a cat")
(newline)
(display "Moeiw")
(newline)

When run

> (load "dick.scm")
I am a dick
I am a cat
Moeiw

namespace name 'Glue' could not be found

@leppie -- I've tried compiling IronScheme in VS 2019, 2017, and 2015. After doing the automatic migrations, setting the starting project to Set IronScheme.Console, and setting the solution profile to release, I always get this build error:

Error CS0246 The type or namespace name 'Glue' could not be found (are you missing a using directive or an assembly reference?) IronScheme C:\Users\Aaron Lanterman\Documents\GitHub\IronScheme\IronScheme\IronScheme\Compiler\Generator.Helpers.cs 21 Active

I also get a bunch of "metadata file XYZ could not be found" errors, which vary depending on which version I'm trying, although I suspect those are symptoms of other issues.

It looks like Glue is defined in IronScheme.Closures.il, so I suspect the problem is related to these messages that appear on the compiler output log:

IronScheme.Closures -> C:\Users\Aaron Lanterman\Desktop\IronScheme\IronScheme.Closures\bin\Release\IronScheme.Closures.dll
Could not open Lanterman\Desktop\IronScheme\DEVELOPMENT.snk

***** FAILURE *****
IronScheme.Closures.il(92) : error -- Failed to open key file 'C:\Users\Aaron': 0x00000002

make-string, open-string-input-port and UTF-8

Latest release:

> (open-string-input-port "a")
#<textual-input-port>
> (open-string-input-port "ä")
#<textual-input-port>
> (open-string-input-port (make-string 1 (integer->char 127)))
Unhandled CLR exception during evaluation:
CLR Exception: System.InvalidCastException
System.InvalidCastException: Specified cast is not valid.
  at #.ironscheme.io.ports::open-string-input-port (System.Object str) [0x0003f] in <16cd200c5d96470892323901f0226e81>:0
> (string-ref (make-string 1 (integer->char 127)) 0)
#\delete
> (bytevector-length (string->utf8 (make-string 1 (integer->char 127))))
1
> (bytevector-u8-ref (string->utf8 (make-string 1 (integer->char 127))) 0)
127

Building under Ubuntu 16.04

Hi, while I'm sure that I have followed all the instructions, i have somehow come to miss some step somewhere to get IronScheme built under Ubuntu 16.04.
What information can I provide you to help you help me get IronScheme up and running under Ubuntu.
Why Ubuntu? Because I got a machine running FreeDOS since I cannot afford a Microsoft Windows license, yet.

Make Builtins.IsTrue smaller, so it can be inlined

Current code is something like:

static readonly object FALSE = false, TRUE = true;

public static bool IsTrue(object arg)
{
  if (!(arg is bool) || arg == TRUE)
  {
       return true;
  }
  if (arg == FALSE)
  {
    return false;
  }
  return (bool)arg;
}

This is 35 bytes, need it to be 32 or less.

https://sharplab.io/#v2:EYLgtghgzgLgpgJwDQxASwDYB8ACAmARgFgAoHAZgAJ9KBhSgb1MpcudZwIDZKE4IAJgHsAdhgCelIcABWcAMYxKAMQCCAGQDKAUUoBeSgDMIGKHCSUAKgCUAqroMwEAVzgBuUuxYVq3SsCEhDEoASShLFzgACmk5RUoIBABzAEovRnSWNENKKIBCKMSkyjQof0CMFMosLATk/QMbezSSVlYmVrau6gB2SidXD062gF9MkpzC+r0DNS1tFu6O7u8+41N3cbHhjj6ogKCUoqHR0hGgA==

Lack of documentation

I would be nice if we could see the old project documentation of IronScheme in the repository

bytevector-uint-set! only works with size={1,2,4,8}

Hello @leppie! The bytevector-uint-set! procedure fails when size is e.g. 3:

IronScheme 1.0.123-11d458e github.com/leppie/IronScheme © 2007-2016 Llewellyn Pritchard (.NET 4.0 64-bit)
> (let ((bv (make-bytevector 4))) (bytevector-uint-set! bv 0 1 (endianness big) 4) bv)
#vu8(0 0 0 1)
> (let ((bv (make-bytevector 4))) (bytevector-uint-set! bv 0 1 (endianness big) 3) bv)
Unhandled CLR exception during evaluation:
CLR Exception: System.ArgumentException
System.ArgumentException: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
  at System.Buffer.BlockCopy (System.Array src, System.Int32 srcOffset, System.Array dst, System.Int32 dstOffset, System.Int32 count) [0x000b1] in <d0e12f672b88444ab4b6d9b2ecf20142>:0 
  at #.ironscheme.bytevectors::bytevector-copy! (System.Object bv1, System.Object s1, System.Object bv2, System.Object s2, System.Object len) [0x000f4] in <9213e0abc0f54f4f8232b36ca750d089>:0 
  at #.ironscheme.bytevectors::bytevector-uint-set! (System.Object bv, System.Object k, System.Object n, System.Object end, System.Object size) [0x00297] in <9213e0abc0f54f4f8232b36ca750d089>:0 
  at eval-core(004).anon$2 (System.Object bv) [0x00018] in <f90aeb9047d14dfe8356f1f3c295c93d>:0 
  at IronScheme.Scripting.ScriptCode.Run (IronScheme.Scripting.CodeContext codeContext, System.Boolean tryEvaluate) [0x0004a] in <9213e0abc0f54f4f8232b36ca750d089>:0 
  at IronScheme.Scripting.ScriptCode.Run (IronScheme.Scripting.ScriptModule module) [0x00020] in <9213e0abc0f54f4f8232b36ca750d089>:0 
  at IronScheme.Runtime.Builtins+<>c__DisplayClass52_1.<CompileCore>b__1 () [0x00015] in <9213e0abc0f54f4f8232b36ca750d089>:0 
  at #.ironscheme.exceptions::dynamic-wind (System.Object in, System.Object proc, System.Object out) [0x0009c] in <9213e0abc0f54f4f8232b36ca750d089>:0 
  at #.ironscheme.exceptions::dynamic-wind (System.Object in, System.Object proc, System.Object out) [0x0009c] in <9213e0abc0f54f4f8232b36ca750d089>:0 
  at IronScheme.Runtime.Builtins.CallWithCurrentContinuation (System.Object fc1) [0x00031] in <9213e0abc0f54f4f8232b36ca750d089>:0 
  at IronScheme.Runtime.R6RS.Exceptions.WithClrExceptionHandler (System.Object handler, System.Object thunk) [0x0000e] in <9213e0abc0f54f4f8232b36ca750d089>:0 

Found with IronScheme 1.0.123-11d458e (.NET 4.0 64-bit) on Mono 5.18.0.240+dfsg-3.

Miscompilation of classical optional arguments

I'm using SRFI 115 in my semver package and found a bug in IronScheme that affects the reference implementation of that SRFI. Under some circumstances the classical code that implements optional arguments is miscompiled:

(import (rnrs))
(define ~none 0)
(define (f . x*)
  (let ((flags (if (pair? x*) (car x*) ~none)))
    flags))
(begin (write (f)) (newline))

If this program is run as a script it prints (). If it's run from the REPL it prints 0, which is the correct output.

Found with IronScheme 1.0.120-e8d1612 (.NET 4.0 64-bit) and Mono 5.18.0.240+dfsg-3.

bitwise-bit-copy and fxbit-copy don't conform to R6RS

These functions are supposed to have the interface (bitwise-bit-copy dest index source), and set the index'th bit of dest to the index'th bit of source, returning dest. But IronScheme only accepts 0 and 1 as a source.

Trying to use IronScheme with Unity on iOS

When I try to use IronScheme with iOS I run into a problem. Note: I'm able to use IronScheme (IronScheme.0.9.109887 from NuGet) with Unity Pro 4.5.2f1 building an app for PC/Mac successfully. My test code is an empty project that accesses IronScheme like this (I'm trying to make sure I don't JIT anything):

    Callable f = IronScheme.RuntimeExtensions.Eval<Callable>("list");

The error that I get is this (the full trace is given below):

ExecutionEngineException: Attempting to JIT compile method 'System.Collections.Generic.GenericEqualityComparer`1<IronScheme.Scripting.SymbolId>:.ctor ()' while running with --aot-only.

I don't think this actually has anything to do with the calling code. I'm guessing there's some JIT that goes on normally. iOS doesn't allow JIT only AOT, which is fine so long as I can compile the code beforehand.

2014-07-25 15:12:55.593 ProductName[22840:60b] -> registered mono modules 0x1d75840
-> applicationDidFinishLaunching()
Mono path[0] = '/var/mobile/Applications/9281432C-90AB-4B4C-B3B5-7AC1A1CA0EAA/ProductName.app/Data/Managed'
Mono config path = '/var/mobile/Applications/9281432C-90AB-4B4C-B3B5-7AC1A1CA0EAA/ProductName.app/Data/Managed'
PlayerConnection initialized from /var/mobile/Applications/9281432C-90AB-4B4C-B3B5-7AC1A1CA0EAA/ProductName.app/Data (debug = 0)
PlayerConnection initialized network socket : 0.0.0.0 55000
Multi-casting "[IP] 10.10.46.169 [Port] 55000 [Flags] 2 [Guid] 1589407710 [EditorId] 3858825550 [Version] 1048832 [Id] iPhonePlayer(Shane-Celiss-iPhone):56000 [Debug] 0" to [225.0.0.222:54997]...
PlayerConnection already initialized - listening to [10.10.46.169:55000]
-> applicationDidBecomeActive()
Renderer: Apple A7 GPU
Vendor:   Apple Inc.
Version:  OpenGL ES 2.0 Apple A7 GPU - 27.23
GL_OES_depth_texture GL_OES_depth24 GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_mapbuffer GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_vertex_array_object GL_EXT_blend_minmax GL_EXT_color_buffer_half_float GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_discard_framebuffer GL_EXT_draw_instanced GL_EXT_instanced_arrays GL_EXT_map_buffer_range GL_EXT_occlusion_query_boolean GL_EXT_pvrtc_sRGB GL_EXT_read_format_bgra GL_EXT_separate_shader_objects GL_EXT_shader_framebuffer_fetch GL_EXT_shader_texture_lod GL_EXT_shadow_samplers GL_EXT_sRGB GL_EXT_texture_filter_anisotropic GL_EXT_texture_rg GL_EXT_texture_storage GL_APPLE_copy_texture_levels GL_APPLE_framebuffer_multisample GL_APPLE_rgb_422 GL_APPLE_sync GL_APPLE_texture_format_BGRA8888 GL_APPLE_texture_max_level GL_IMG_read_format GL_IMG_texture_compression_pvrtc 
Creating OpenGLES2.0 graphics device
Initialize engine version: 4.5.2f1 (9abb1b59b47c)
Begin MonoManager ReloadAssembly
Platform assembly: /var/mobile/Applications/9281432C-90AB-4B4C-B3B5-7AC1A1CA0EAA/ProductName.app/Data/Managed/UnityEngine.dll (this message is harmless)
Loading /var/mobile/Applications/9281432C-90AB-4B4C-B3B5-7AC1A1CA0EAA/ProductName.app/Data/Managed/UnityEngine.dll into Unity Child Domain
Non platform assembly: /private/var/mobile/Applications/9281432C-90AB-4B4C-B3B5-7AC1A1CA0EAA/ProductName.app/Data/Managed/System.dll (this message is harmless)
Non platform assembly: /private/var/mobile/Applications/9281432C-90AB-4B4C-B3B5-7AC1A1CA0EAA/ProductName.app/Data/Managed/Mono.Security.dll (this message is harmless)
Non platform assembly: /private/var/mobile/Applications/9281432C-90AB-4B4C-B3B5-7AC1A1CA0EAA/ProductName.app/Data/Managed/System.Configuration.dll (this message is harmless)
Non platform assembly: /private/var/mobile/Applications/9281432C-90AB-4B4C-B3B5-7AC1A1CA0EAA/ProductName.app/Data/Managed/System.Xml.dll (this message is harmless)
Non platform assembly: /private/var/mobile/Applications/9281432C-90AB-4B4C-B3B5-7AC1A1CA0EAA/ProductName.app/Data/Managed/System.Security.dll (this message is harmless)
Platform assembly: /var/mobile/Applications/9281432C-90AB-4B4C-B3B5-7AC1A1CA0EAA/ProductName.app/Data/Managed/Assembly-CSharp.dll (this message is harmless)
Loading /var/mobile/Applications/9281432C-90AB-4B4C-B3B5-7AC1A1CA0EAA/ProductName.app/Data/Managed/Assembly-CSharp.dll into Unity Child Domain
Non platform assembly: /private/var/mobile/Applications/9281432C-90AB-4B4C-B3B5-7AC1A1CA0EAA/ProductName.app/Data/Managed/IronScheme.dll (this message is harmless)
Platform assembly: /var/mobile/Applications/9281432C-90AB-4B4C-B3B5-7AC1A1CA0EAA/ProductName.app/Data/Managed/IronScheme.dll (this message is harmless)
Loading /var/mobile/Applications/9281432C-90AB-4B4C-B3B5-7AC1A1CA0EAA/ProductName.app/Data/Managed/IronScheme.dll into Unity Child Domain
- Completed reload, in  0.081 seconds
ExecutionEngineException: Attempting to JIT compile method 'System.Collections.Generic.GenericEqualityComparer`1<IronScheme.Scripting.SymbolId>:.ctor ()' while running with --aot-only.

  at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
  at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in <filename unknown>:0 
  at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0 
  at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0 
  at System.Collections.Generic.EqualityComparer`1[IronScheme.Scripting.SymbolId]..cctor () [0x00000] in <filename unknown>:0 
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for System.Collections.Generic.EqualityComparer`1
  at System.Collections.Generic.Dictionary`2[IronScheme.Scripting.SymbolId,IronScheme.Scripting.Generation.CodeGen].Init (Int32 capacity, IEqualityComparer`1 hcp) [0x00000] in <filename unknown>:0 
  at System.Collections.Generic.Dictionary`2[IronScheme.Scripting.SymbolId,IronScheme.Scripting.Generation.CodeGen]..ctor () [0x00000] in <filename unknown>:0 
  at IronScheme.Scripting.Generation.CodeGen..cctor () [0x00000] in <filename unknown>:0 
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for IronScheme.Scripting.Generation.CodeGen
  at IronScheme.Scripting.ScriptDomainManager.CreateModule (System.String name, IronScheme.Scripting.Scope scope, IronScheme.Scripting.ScriptCode[] scriptCodes) [0x00000] in <filename unknown>:0 
  at IronScheme.Scripting.Hosting.ScriptHost.CreateDefaultModule (IronScheme.Scripting.ScriptModule& defaultModule) [0x00000] in <filename unknown>:0 
  at IronScheme.Scripting.Hosting.ScriptHost.get_DefaultModule () [0x00000] in <filename unknown>:0 
  at IronScheme.Compiler.BaseHelper.Initialize (IronScheme.Hosting.IronSchemeLanguageProvider ironSchemeLanguageProvider) [0x00000] in <filename unknown>:0 
  at IronScheme.Hosting.IronSchemeLanguageProvider.Initialize () [0x00000] in <filename unknown>:0 
  at IronScheme.Hosting.IronSchemeLanguageProvider..ctor (IronScheme.Scripting.ScriptDomainManager x) [0x00000] in <filename unknown>:0 
  at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
Rethrow as InvalidImplementationException: Type 'IronScheme.Hosting.IronSchemeLanguageProvider' doesn't provide a suitable public constructor or its implementation is faulty.
  at IronScheme.Scripting.Utils.ReflectionUtils.CreateInstance[LanguageProvider] (System.Type actualType, System.Object[] args) [0x00000] in <filename unknown>:0 
  at IronScheme.Scripting.ScriptDomainManager+LanguageProviderDesc.LoadProvider (IronScheme.Scripting.ScriptDomainManager manager) [0x00000] in <filename unknown>:0 
  at IronScheme.Scripting.ScriptDomainManager.GetLanguageProvider (System.Type type) [0x00000] in <filename unknown>:0 
  at IronScheme.RuntimeExtensions..cctor () [0x00000] in <filename unknown>:0 
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for IronScheme.RuntimeExtensions
  at SchemeTest.Start () [0x00000] in <filename unknown>:0 

(Filename:  Line: -1)

Miscompilation of test-error from SRFI 64

Hello @leppie! The test-error syntax from SRFI 64 generates invalid IL:

# mono /usr/local/IronScheme/IronScheme.Console-v4.exe
IronScheme 1.0.121-393d598 github.com/leppie/IronScheme © 2007-2016 Llewellyn Pritchard (.NET 4.0 64-bit)
> (import (srfi :64 testing))
> (test-begin "test-error")
%%%% Starting test test-error
> (test-error (error #f "foo"))
Unhandled CLR exception during evaluation:
CLR Exception: System.InvalidProgramException
System.InvalidProgramException: Invalid IL code in eval-core(092):anon#1#2#3#4#5#6#7#8#9$455 (IronScheme.Scripting.CodeContext): IL_0060: call      0x2b000001


  at IronScheme.Runtime.OptimizedBuiltins.CallWithValues (System.Object producer, System.Object consumer) [0x0000e] in <3ccc9951e44148ff9fdab1b5a89b87c4>:0 
  at #.ironscheme.exceptions::dynamic-wind (System.Object in, System.Object proc, System.Object out) [0x0009c] in <3ccc9951e44148ff9fdab1b5a89b87c4>:0 
  at eval-core(092).anon#1#2#3$448 (System.Object 1918) [0x00055] in <598dce2de6674adba25971b8b94860db>:0 
  at IronScheme.Runtime.Builtins.CallWithCurrentContinuation (System.Object fc1) [0x00031] in <3ccc9951e44148ff9fdab1b5a89b87c4>:0 
  at eval-core(092).anon$447 (System.Object r) [0x0002c] in <598dce2de6674adba25971b8b94860db>:0 
  at IronScheme.Scripting.ScriptCode.Run (IronScheme.Scripting.CodeContext codeContext, System.Boolean tryEvaluate) [0x0004a] in <3ccc9951e44148ff9fdab1b5a89b87c4>:0 
  at IronScheme.Scripting.ScriptCode.Run (IronScheme.Scripting.ScriptModule module) [0x00020] in <3ccc9951e44148ff9fdab1b5a89b87c4>:0 
  at IronScheme.Runtime.Builtins+<>c__DisplayClass52_1.<CompileCore>b__1 () [0x00015] in <3ccc9951e44148ff9fdab1b5a89b87c4>:0 
  at #.ironscheme.exceptions::dynamic-wind (System.Object in, System.Object proc, System.Object out) [0x0009c] in <3ccc9951e44148ff9fdab1b5a89b87c4>:0 
  at #.ironscheme.exceptions::dynamic-wind (System.Object in, System.Object proc, System.Object out) [0x0009c] in <3ccc9951e44148ff9fdab1b5a89b87c4>:0 
  at IronScheme.Runtime.Builtins.CallWithCurrentContinuation (System.Object fc1) [0x00031] in <3ccc9951e44148ff9fdab1b5a89b87c4>:0 
  at IronScheme.Runtime.R6RS.Exceptions.WithClrExceptionHandler (System.Object handler, System.Object thunk) [0x0000e] in <3ccc9951e44148ff9fdab1b5a89b87c4>:0 

The bug is seen with both 1.0.120-e8d1612 and 1.0.121-393d598 (.NET 4.0 64-bit) on Mono 5.18.0.240+dfsg-3.

InvalidProgramException

I'm trying to use IronScheme in Unity3d, using this project here:

https://github.com/saolsen/IronSchemeUnity

When I do this, things are fine:

(clr-new Vector3 0 0 0)

I get a new vector as expected. But when I try to wrap this in my own convenience function, things go awry:

(define (new-pos x y z)
  (clr-new Vector3 x y z))

I get this error when I try to call (new-pos 0 0 0):

System.InvalidCastException: Cannot cast from source type to destination type.
at eval-core(004).new-pos (object,object,object) <IL 0x00001, 0x0006a>
at eval-core(005).Initialize (IronScheme.Scripting.CodeContext) <IL 0x00026, 0x00138>
at IronScheme.Scripting.ScriptCode.Run (IronScheme.Scripting.CodeContext,bool) <IL 0x0004a, 0x001ac>
at IronScheme.Scripting.ScriptCode.Run (IronScheme.Scripting.ScriptModule) <IL 0x00021, 0x0011e>
at IronScheme.Runtime.Builtins/<>c__DisplayClass11.<CompileCore>b__b () <IL 0x00015, 0x000bb>
at IronScheme.Runtime.Closure/SimpleClosure.Call () <IL 0x00018, 0x0009b>
at #.psyntax.expander..eval (object,object) <IL 0x00073, 0x00330>
at #.psyntax.main..eval-embedded (object) <IL 0x00017, 0x000c1>
at (wrapper dynamic-method) object.##4 (object[],IronScheme.Scripting.CodeContext) <IL 0x00003, 0x0005f>
at IronScheme.Scripting.ScriptCode.Run (IronScheme.Scripting.CodeContext,bool) <IL 0x0006e, 0x00277>
at IronScheme.Scripting.ScriptCode.Run (IronScheme.Scripting.ScriptModule) <IL 0x00021, 0x0011e>
at IronScheme.Scripting.Hosting.CompiledCode.Evaluate (IronScheme.Scripting.IScriptModule) <IL 0x00029, 0x0016c>
at IronScheme.Scripting.Hosting.ScriptEngine.Evaluate (string,IronScheme.Scripting.IScriptModule) <IL 0x00009, 0x00083>
at IronScheme.Scripting.Hosting.ScriptEngine.Evaluate (string) <IL 0x00003, 0x00056>
at IronScheme.RuntimeExtensions.EvalWithEnvironment (string,string,object[]) <IL 0x00105, 0x00689>
at IronScheme.RuntimeExtensions.Eval (string,object[]) <IL 0x00007, 0x0005e>
at SchemeReplWindow.Eval (string) [0x00026] in /Users/thoughtstem/Dev/CodeSpells2/codespells_terrain_test/Assets/Editor/SchemeReplWindow.cs:34

UnityEngine.Debug:Log(Object)
SchemeReplWindow:Eval(String) (at Assets/Editor/SchemeReplWindow.cs:38)
SchemeReplWindow:OnGUI() (at Assets/Editor/SchemeReplWindow.cs:69)
UnityEditor.DockArea:OnGUI()


read greedy end to the input port

I'm not sure whether or not it is IronScheme's bug but it is somewhat strange behaviour..

For example, string "\" \\\"\" (string-append \"" is accepted by the reader. When I use string port which was created with SRFI-6 open-input-string, it yields an exception.

root@145aae4312d6:/yuni# mono /ironscheme/IronScheme/IronScheme.Console-v4.exe
IronScheme 1.0.91-07f20bd github.com/leppie/IronScheme © 2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Llewellyn Pritchard (.NET 4.0 64-bit)
> "\" \\\"\" (string-append \""
"\" \\\"\" (string-append \""
> (define s "\" \\\"\" (string-append \"")
> s
"\" \\\"\" (string-append \""
> (import (srfi :6))
> (read (open-input-string s))
Unhandled exception during evaluation:
&lexical
&message: "invalid syntax"
&irritants: ("\" \\\"\" (string-append \"")

Reproduced on Mono-64bit from official mono Docker image and .Net 4 with Win8.1 amd64.

port-has-port-position? fails on textual input ports

Hello @leppie! The port-has-port-position? and port-has-set-port-position!? procedures raise an assertion when applied to textual input ports:

IronScheme 1.0.122-21859af github.com/leppie/IronScheme © 2007-2016 Llewellyn Pritchard (.NET 4.0 64-bit)
> (define p (open-input-file "/etc/hosts"))
> (port-has-port-position? p) 
Unhandled exception during evaluation:
&assertion
&who: port-has-port-position?
&message: "not a port"
&irritants: (#<textual-input-port>)

> (port-has-set-port-position!? p) 
Unhandled exception during evaluation:
&assertion
&who: port-has-set-port-position!?
&message: "not a port"
&irritants: (#<textual-input-port>)

> (port-position p)
Unhandled exception during evaluation:
&assertion
&who: port-position
&message: "not supported"
&irritants: (#<textual-input-port>)

They should return #f since it appears that port positions are not supported on textual input ports (although that would be a good feature to have).

Found with IronScheme 1.0.122-21859af (.NET 4.0 64-bit) on Mono 5.18.0.240+dfsg-3.

Allow compiled libraries to load from library-path

Background

I like to support IronScheme in a bigger R6RS Scheme project, that consists of a lot of depending libraries. So far, Larceny, Racket, Guile and Petite Chez Scheme are supported. Except Petite, all of these systems provide means to precompile libraries to speed up the loading and execution time. Of course, each system requires some configuration, such that its virtuell machine can find the precompiled libraries. I developed a bunch of Bash scripts providing a common interface to install my libraries and execute them; thus, to configure the supported Scheme systems.

Problem

I would like to do the same for IronScheme. I tried to use its compile function to generate dll files and setup its library resolution paths using library-path, in particular (library-path list-of-resolution-paths). I am struggling for the following reasons:

  • compile saves the dll files it generates in IronScheme's root directory (the one the used IronScheme console or IronScheme.dll is in; I am not sure which of both). One of my policies is to not touch anything outside of my project, in particular not to generate or delete files outside of my project. I also would like to save libraries in different directories.
  • Changing the library path via library-path seems not to influence dll resolution. The precompiled libraries are not found if not in IronScheme's root directory, cluttering it up.

Question summary

My main concerns are the following:

  1. How are precompiled dll libraries resolved?
  2. Is there a way to setup the dll resolutions paths similar like library-path does for sources?
  3. Are there flags to configure such paths when calling IronScheme.Console, such that they can be set outside of the program to run?
  4. Is there a way to compile a single library to a dll without IronScheme automatically compiling the transitive closure of its dependencies?
  5. Can the output path, where compiled libraries are generated, be changed? Does compile provide further configuration arguments?

Benefits of a solution

I think it is a natural next step for big projects to move from source code loading to precompiled libraries (assemblies for .NET). It would be good if IronScheme supports user build processes with some way to configure generation and loading.

Another advantage is, that I am doing a lot of profiling, comparing major R6RS Scheme systems in a real setup (not small toy-benchmark-programs). My project contains very fast executing examples (less than a second, at most a few seconds), where for example Guile heavily benefits from its fast VM startup and program loading time, up to very heavy computations, running for several minutes, where for example Larceny is a much better choice than Guile. It might be interesting for IronScheme to find its place in these scenarios.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.