Scriptcs gets new REPL commands and is now better than ever

Β· 439 words Β· 3 minutes to read

Yesterday the scriptcs project got an little injection of awesomeness through a set of new REPL commands we have added. You can now conveniently access a bunch of contextual information about your REPL session - the idea is to make your work with the REPL smoother, more productive and, of course, more enjoyable. Let’s quickly walk through them in this post.

By the way, it’s a good moment to remind that the REPL command infrastructure is fully extensible - so you can easily build up your own commands. Watch my talk from NDC Oslo if you are interested, there is an example in there.

Getting started πŸ”—

This is not yet released - will be part of the next release, 0.12 - so for now you will have to use nightly builds to try it out (or build from source). Instructions are available here

Help πŸ”—

REPL now has a :help command which lists all the commands available along with a short description.

scriptcs-help

References πŸ”—

Typing in :references will show you the list of assemblies currently referenced by your REPL session. As soon as you reference more (i.e. using #r) they will obviously show up too - in the example below we import JSON.NET and you can see it being added to the list. Notice that some of the references have no “dll” extension - those are GAC references.

scriptcs-references

Usings πŸ”—

Typing in :usings will show you the list of namespaces currently imported into your REPL session. Similarily to the references, as soon as you import more, they will show up too. I used Newtonsoft.Json as an example here again.

scriptcs-usings

Vars πŸ”—

This might be the coolest of all, it will show you the local variables that currently exist in the REPL session - you just need to type in :vars. Since in REPL you can overwrite variables, the output of the command will adjust accordingly as your REPL session lives on.

scriptcs-vars

Alias πŸ”—

:alias allows you to alias one command with a different name. This way you can use your own aliases if the built-in names are too long for you, or you simply don’t like them. Currently aliasing only lives on for the duration of the REPL session, however we do plan for allowing of persistence of the aliases in the future.

scriptcs-alias

Interestingly you not only have to alias using a basic string-to-string mapping, but you can actually use a string variable from your REPL too - like in the example below.

scriptcs-alias2

All right, take this for a spin now with the nightlies or the source, and give us some feedback at Github. Otherwise, wait for 0.12 release πŸ™‚ Hopefully you like it!

About


Hi! I'm Filip W., a software architect from ZΓΌrich πŸ‡¨πŸ‡­. I like Toronto Maple Leafs πŸ‡¨πŸ‡¦, Rancid and quantum computing. Oh, and I love the Lowlands 🏴󠁧󠁒󠁳󠁣󠁴󠁿.

You can find me on Github, on Mastodon and on Bluesky.

My Introduction to Quantum Computing with Q# and QDK book
Microsoft MVP