Not really. The language could be fully strong-typed, but also support typeless parameters. The compiler would analyse the function, and determine the restrictions each typeless parameter required, then give compiler errors if the code tries to pass a variable which doesn't meet those restrictions. These functions would be template function, which new version being compiled out with each unique set of param types used (therefor, special restrictions would be required for key Shared Object functions). eg:
Originally Posted by mark45
In the code above, two versions of 'foo' would be compiled out... one taking in a (float, int), and one taking in an (int, int).
func foo(x, y:int) # 'x' is typeless, 'y' must be an int
return x * y
var s = "text" # 's' is text
var i = 0 # 'i' is an int
var f = 0.0 # 'f' is a float
var r = foo(s, i) # error: can't pass text as a first parameter
var r = foo(f, i) # works: because compiler can multiply a 'int' and a 'float'
var r = foo(i, i) # works: compiler can compile 'int' and 'int'
As far as memory safety without garbage-collection, the language could define a distinction between a 'var' (a memory "owner" which can't be null), and a 'ref' (a memory reference, which can't "own" memory). Vars would always be deleted at the end of their scope (unless returned), or when removed from arrays, etc.. whereas References to that data would simple be set to null. example:
There's a lot of other stuff to that, but I think it would be possible to do something like that to achieve memory safety without a GC or Ref-Counting. You'd also need a low-level 'ptr' type which wouldn't have any restrictions and require manual memory management for advanced situations, etc..
ref x : int
ref y : num
var z = 0
var w = 0.0
x => z
x = 1 # sets 'z' to 1
y => w
y = 1.0 # sets 'w' to 1.0
# auto cleanup code injected here
# In this case, the code would look like:
# x => null
# Optimization: We don't need to set 'y' to null
# because it's not directly accessed after this scope.
# PS. Technically, we also don't need to delete 'z' & 'w'
# since they would be created on the stack, but I put it
# in to illustrate what normally happens with heap vars.
x = 2 # error: 'x' is null
var n = 2.0
y => n
y = 3.0 # sets 'n' to 3.0
# auto cleanup code: