• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 360
  • Last Modified:

type checking

In C/Java
int abc;
helps compiler to
1) conclude  invalid operations on abc
2) memory allocation to abc

But what about scheme interpreter or lisp compiler?
How do they decide?

1 Solution
You might get more answers if you asked about javascript, which is also a loosely typed interpretive language.  The grammar is less strong, though, so it's probably good to use scheme and lisp as examples.

C and Java are strongly typed languages, which as you noted helps with the compiler (and runtime), for performance and for more intangible things like the ability of programmers to effectively write and maintain code.

It can be very helpful not to have strong typing, though, hence the more interpretive languages.  Interpretive languages still work with the same math and hardware, so at some point they try to multiply numbers or concatenate strings.  In general, loosely typed languages try to do as much as possible without caring about the type of the variable (which is generally a lot).  Then they usually examine the variable value to determine the type if it cannot be determined from other information.  The operations being performed, for example, would usually determine the expected type of the variable, and if the variable value turned out not to be that type, then some sort of error condition should occur.  In the early days that was often a memory fault, or an error much further down in the code, but nowadays even loosely typed languages catch these sorts of errors and attempt to fail in a useful way.

You should check some computer science textbooks on compilers to fully answer your question.  Wikipedia has a nice, short article on variables:
mohet01Author Commented:

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now