Name: Anonymous 2013-11-19 12:18
Ask /prog/ anything.
Although don't expect an answer or even a good one.
Also, keep it /prog/ related.
Although don't expect an answer or even a good one.
Also, keep it /prog/ related.
Estimating the Airspeed Velocity of an Unladen Swallow
Although 47 of the 74 worldwide swallow species are found in Africa, 1 only two species are named after the continent: the West African Swallow (Hirundo domicella) and the South African Swallow (Hirundo spilodera), also known as the South African Cave Swallow.
style.org/unladenswallow/ More from style.org
Why is pascal not suitable for systems programming?
What's the key differences with Algol 60 and 68?
Why was Cobol so popular for data processing applications?
malloc()
wasn't a thing yet, it's surprisingly good at taking strings apart and splicing them back together. int *var
int var = 420;
int *pointertovar = *var;
int **pointertopointertovar = **var (== *pointertovar);
int varaddress = &var;
int pointertovaraddress = &pointertovar;
typeof(*var)
is int
.typeof(var)
is int *
(the address of an int
value).typeof(&var)
is int **
(the address of a pointer which in turn contains the address of an int
value). Record *
that I declared in main()
to a function named input(Record *Something)
so that I can ask for some data and call insert()
. Whenever I try to print the data, the Record *
I declared first in main()
only seems to refer to NULL
int insert(Record *Phonebook, char * lname, char * fname, char * mobile)
{
/*
RETURN 0 IF SUCCESSFUL.
*/
Record *New, *Temp;
New = (Record *) malloc(sizeof (Record));
/* If malloc returns a null pointer... */
if (!New) {
return 1;
}
New->lastname = (char *) malloc(strlen(lname) + 1);
strcpy(New->lastname, lname);
printf("%s", New->lastname);
New->firstname = (char *) malloc(strlen(fname) + 1);
strcpy(New->firstname, fname);
New->mobilenum = (char *) malloc(strlen(mobile) + 1);
strcpy(New->lastname, mobile);
New->Next = NULL;
if (Phonebook == NULL) {
Phonebook = New;
} else {
Temp = Phonebook;
while (Temp->Next != NULL) {
Temp = Temp->Next;
}
Temp->Next = New;
}
return 0;
}
Did I fuck up the scoping and deleted the *Phonebook in input() when it ended?
Record **
, and rewrite that last section as follows:if (Phonebook != NULL) {
if (*Phonebook == NULL) {
*Phonebook = New;
} else {
Temp = *Phonebook;
// ...
}
} else {
// Signal an error and/or deallocate New
}
How do you feel about cdr coding and GC-time list compaction?
From the name it sounds like it would only work with memory models that run on handles instead of direct pointers.Depends. If you don't want a non-incremental ("stop-the-world") collector (and you almost never do except when implementation simplicity/size is the most important thing) then you will have to do tricky, nasty and possibly inefficient things to avoid using handles. Using handles instead of pointers at most doubles your cache misses, and you can cache pointer-handle associations in a per-thread structure so you don't waste cache on handle table entries that you won't use anyway.
Could you tell me more about it (...)The GC has the `power' to lock structures, and it [i]has[/i] traverse them anyway (to mark things), so while it's doing its marking stuff it could also compact lists into unrolled lists as it goes through them and move them to a new location.
(...) and perhaps point out some implementations?I am not aware of any, sorry. I am not familiar with many languages' implementations.
Why Lisp?not a correct question. Try "Why use Lisp?" on a search engine. We have answered this question xx times.
Why functional programming in our current computer technology?Pffft hahahaha. https://encrypted.google.com/search?hl=en&q=current%20computer%20technology
About 273,000,000 results (0.32 seconds)
Why is there no SICP 3rd edition yet?There's, and it's in FIoC. You are welcome to update your onw with R7RS &/| R2004.
Bet you creeps did not know about Common Lisp HyperSpec:et al.