Name: Anonymous 2014-12-02 12:11
Why hasn't anyone made C that doesn't look like dogshit?
1) C wouldn't need a special syntax for function types because it doesn't have function types. It forces you to use (void *) for all function types.Wait, what?
typedef int* IntPtrIt's not special syntax.
If simplicity was wanted, why not use s-exps?Because it would look like shit for C.
function main(argc: Int, argv: [[Char]]) -> Int do
var ch: Int
var stdout_lock: FileLock
setlocale(LC_TYPE, "")
while (ch = getopt(argc, argv, "belnstuv")) != 1 do
case ch of
'b' =>
bflag = nflag = 1
'e' =>
eflag = vflag = 1
'l' =>
lflag = 1
'n' =>
nflag = 1
else
usage()
end case
end while
argv += optind
if lflag then
stdout_lock.l_len = 0
stdout_lock.l_start = 0
stdout_lock.l_type = F_WRLCK
stdout_lock.l_whence = SEEK_SET
if fcntl(STDOUT_FILENO, F_SETLKW, addr_of stdout_lock) == -1 then
err(EXIT_FAILURE, "stdout")
end if
end if
if bflag oror eflag oror nflag oror sflag oror tflag oror vflag then
scanfiles(argv, 1)
else
scanfiles(argv, 0)
end if
if fclose(stdout) then
err(1, "stdout")
end if
exit(rval)
end function
(void *)
.which all have the same useless type (void *)This is false, void * is a data pointer, not a function pointer. You can't point to a function with void *.
functionhttp://reddit.com/r/lua
var
then
end if
(preprocessor-include-file "stdio.h")
(int main (function-of (int argc) ((pointer-to (pointer-to 'char) argv))))
(begin)
(for-loop)
(begin)
(if-statement (< argc 2))
(begin)
(function-call puts "y")
(end)
(else-statement)
(begin)
(for-loop (int i 1) (< i argc) (++ i))
(begin)
(if-statement (> i 1))
(begin)
(function-call putchar #\space)
(end)
(function-call printf "%s" (array-get argv i))
(end)
(function-call putchar #\n)
(end)
(end)
(end)
As discussed above, covariant arrays leads to problem with writes into the array. Java and C# deals with this by marking each array object with a type when it is created. Each time a value is stored into an array, the compiler inserts a check that the run-time type of the value is equal to the run-time type of the array. If there is a mismatch, an ArrayStoreException (or ArrayTypeMismatchException in C#) is thrown:
assembly languageAssembly language is fast. LITHP is slow. Other than that, you're right. It is much harder to built skyscrapers in.