I am using DrRacket to debug scheme code using the R5RS language. I am trying to debug over multiple files imported using the load function. I opened both files as the instructions on the Dr Racket site says but when debugging, functions from other files are just skipped over.
Any idea of how to debug multiple files in DrRacket?
At the moment, the debugger cannot go over files other than the one in the definitions window.
(In addition, using the R5RS language and load is a bad way to organize code -- using modules is much better.)
Related
I've been trying to load another file into my Scheme scrip but when I do this,
(load "fn1.lisp")
the error came out as
The port #[input-port 13 for file: "/Users/yiwenzhu/Library/Mobile Documents/com~apple~CloudDocs/work/study/computer/SICP/src_lisp/fn1.lisp"] signalled an error:
The primitive channel-read, while executing the read system call, received the error: Bad address.
How to solve this? Thanks.
load is the only compatible way until R5RS, but after that the standard introduced libraries. Where the files need to be installed is implementation dependent, but the source structure on how to define and use isn't.
Also know that SICP is pre-R5RS so there isn't one modern Scheme implementation that would run the books examples without some compatibility layer. Eg. I have an answer about how to do SICP with DrRacket.
Since we don't know how the file you are trying to include look like or which Scheme implementation you are using I'm afraid I cannot help you further. I can update if you update your question.
I'm completely new to SML and I have no idea how to work with anything related to it.
I am supposed to use the SMLNJ compiler and I'm currently coding using Notepad++.
But how do I compile the program exactly? Do I copy and paste the code in the SMLNJ command line thing? Or is there an environment for SMLNJ I can actually code in and compile my code?
PLEASE HELP!
If by "compile" you mean "compile to a stand-alone executable" -- don't worry about that when first learning the language as a full answer is somewhat involved. In principle it is possible, though there seems to be practical issues (as this excellent answer details).
On the other hand, SML/NJ has a command-line based REPL (Read-Evaluate-Print-Loop) which actually is an compiler. It is an incremental compiler -- meaning that it compiles newly defined functions in the context of currently defined functions. At the very first you will be experimenting with short snippets typed directly into the REPL. Sooner rather than later you will want to write the code in something like NotePad++ . Just write the file, save it with a .sml extension, then in the REPL type
use "filename";
and it loads and compiles your definitions.
A trick that I sometimes use is the following. On the top of my files I have a comment like this:
(* val _ = (use "C:/Programs/sets.sml", OS.Process.system "cls"); *)
Here sets.sml just happens to be an SML file I have on my machine. When I get done editing the file I save it and then copy the insides of the comment (beginning with val and extending to the semicolon) to the clipboard and then paste it into an open SML REPL (using the edit menu for the command window which pops up when you hit the icon in the upper left hand corner of the command window). This loads the definitions and presents you with a cleared REPL for experimenting with your definitions.
Notepad++ seems to lack a syntax definition file for SML (although it has one for F#, which might be close enough). Personally, I do most of my SML using Textpad. This isn't open source but is reasonably priced nagware which is roughly comparable to Notepad++. From their website you can download a useful SML syntax-definition file which does a nice job of logically highlighting your code. I even created a Textpad tool (which for unknown reasons only works sporadically) for automatically saving the file, opening SML, and invoking use on the file name.
I use VS2010 for C++ development, and I often end up doing work in some dll project and after everything compiles nicely I would like to try to run dummy data on some classes, but ofc the fact that it is a dll and not an exe with main makes that a no go. So is there a simple way to do what I want, or Im cursed till eternity to c/p parts of a big project into small testing one?
Ofc changing the type of the project also works, but I would like to have some almost like iteractive shell way of testing functions.
I know this isn't a library or anything, but if you want to run the dll on windows simply without framing it into anything, or writing a script, you can use rundll32.exe within windows. It allows you to run any of the exported functions in the dll. The syntax should be similiar to:
rundll32.exe PathAndNameofDll,exportedFunctionName [ArgsToTheExportedFunction]
http://best-windows.vlaurie.com/rundll32.html -- is a good simple still relevant tutorial on how to use this binary. Its got some cool tricks in there that may surprise you.
If you are wondering about a 64-bit version, it has the same name (seriously microsoft?) check it out here:
rundll32.exe equivalent for 64-bit DLLs
Furthermore, if you wanted to go low level, you could in theory utilize OllyDbg which comes with a DLL loader for running DLL's you want to debug (in assembly), which you can do the same type of stuff in (call exported functions and pass args) but the debugger is more for reverse engineering than code debugging.
I think you have basically two options.
First, is to use some sort of unit tests on the function. For C++ you can find a variety of implementations, for one take a look at CppUnit
The second option is to open the DLL, get the function via the Win32API and call it that way (this would still qualify as unit testing on some level). You could generalize this approach somewhat by creating an executable that does the above parametrized with the required information (e.g. dll path, function name) to achieve the "interactive shell" you mentioned -- if you decide to take this path, you can check out this CodeProject article on loading DLLs from C++
Besides using unit tests as provided by CppUnit, you can still write your own
small testing framework. That way you can setup your Dll projects as needed,
load it, link it, whatever you want and prove it with some simple data as
you like.
This is valueable if you have many Dlls that depend on each other to do a certain job.
(legacy Dlls projects in C++ tend to be hardly testable in my experience).
Having done some frame application, you can also inspect the possibilities that
CppUnit will give you and combine it with your test frame.
That way you will end up with a good set of automated test, which still are
valueable unit tests. It is somewhat hard starting to make unit tests if
a project already has a certain size. Having your own framework will let you
write tests whenever you make some change to a dll. Just insert it into your
framework, test what you expect it to do and enhance your frame more and more.
The basic idea is to separate the test, the testrunner, the testdata and the asserts
to be made.
I’m using python + ctypes to build quick testing routines for my DLL applications.
If you are using the extended attribute syntax, will be easy for you.
Google for Python + ctypes + test unit and you will find several examples.
I would recommend Window Powershell commandlets.
If you look at the article here - http://msdn.microsoft.com/en-us/magazine/cc163430.aspx you can see how easy it is to set up. Of course this article is mostly about testing C# code, but you can see how they talk about also being able to load any COM enabled DLL in the same way.
Here you can see how to load a COM assembly - http://blogs.technet.com/b/heyscriptingguy/archive/2009/01/26/how-do-i-use-windows-powershell-to-work-with-junk-e-mail-in-office-outlook.aspx
EDIT: I know a very successful storage virtualization software company that uses Powershell extensively to test both it's managaged and unmanaged (drivers) code.
What language are NSIS scripts written in?
Is it NSIS's own language or is it a common language or even Assembly itself? Its looks very familiar to Assembly. I've looked on the website to try to find out what language it is but it doesn't explain what language it is.
The instructions that NSIS uses for scripting are sort of a cross
between PHP and assembly.
That is what the manual has to say. The scripting language is unique to NSIS, I don't really see the point of comparing it to other languages. (NSIS evolved from the basic Winamp plugin installer, more history available here)
Several years ago the LogicLib was added which added "high" level macros so you can do basic If's and loops without goto's. Calling functions and plugins still require push'ing parameters to a stack asm style.
The language basically has three types of instructions:
Preprocessor (defines, includes and macros etc), they start with ! (!if 1 > 0)
Attributes/Properties: Icon, Version info etc
Instructions executed during install/uninstall (Instructions are placed inside functions and sections)
The installer UI consists of one or more pages. Each page can execute code based on several callback functions (Show, Leave etc) but most instructions are executed on the instfiles page (A page with a progress bar and log window) The instfiles page executes the code in all the sections. A section is basically a collection of files and instructions used to organize your installer into different parts. If the installer includes a component page, the user is given a list where they can choose which sections to execute.
The full list of instructions can be found in the source (This list does not include plugins and helper macros from external include files) The compiler (makensis.exe) validates and compresses these instructions (along with other files you have included) into a blob that is appended to a small GUI application written in C. This little application interprets these instructions...
It is their own 'language' loosely based on assembler.
From what I understand, it compiles this down to native code, and hence why the installer is so small :)
I am new to LISP, currently using LispWorks and ListBox IDE on window server 2008.
I want to know that, how can we compile and run LISP project, contain 350 LISP source file.
and what will be generate after compilation and how can i run it...?
and what's techniques are available to debug lisp project.
(it is old technology, so I cannot get much help from internet)
LispWorks comes with a lot of documentation. This documentation is also available on their website.
LispWorks can:
organize source code with a system management tool
save images with saved state
compile individual files to loadable machine code
create shared libraries
create stand-alone applications
Their Delivery User Guide describes how to generate applications.
The documentation of DEFSYSTEM describes how to organize source code and how to compile systems.