Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Prog

Name: Anonymous 2012-09-14 7:46

How do I learn how to program or atleast comprehend what the fuck is going on when someone writes out a code?

Keep in mind I literally know nothing about anything dealing with programming, absolutely nothing, I don't even know what it does or can do.

Name: Anonymous 2012-09-14 8:40

>>6
Alternatively, instead of writing Lisp macros, one can manually translate his program into C/C++. Like that:

Code in my DSL:

open FileName | <[T:@4,utf8 L:@4,ul D:@L,y? @Xs]=[[T D] @Xs,r]>


same code translated to C/C++:

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

typedef struct chunk {
  uint8_t Tag[5];
  uint32_t Len;
  uint8_t *Data;
  struct chunk *Next;
} chunk;

chunk *loadChunks(char *FileName) {
  int I, L;
  uint8_t *D, *P, *E;
  chunk *C=0, *T, *N;
  FILE *F = fopen(FileName, "r");
  fseek(F, 0, SEEK_END);
  L = ftell(F);
  D = P = (uint8_t *)malloc(L);
  E = P+L;
  fseek(F, 0, SEEK_SET);
  fread(D, 1, L, F);
  fclose(F);

  while (P < E) {
    T = (chunk *)malloc(sizeof(chunk));
    memcpy(T->Tag, P, 4);
    T->Tag[4] = 0;
    P += 4;
    T->Len = *(uint32_t *)P;
    P += 4;
    T->Data = (uint8_t *)malloc(T->Len);
    memcpy(T->Data, P, T->Len);
    P += T->Len;
    T->Next = C;
    C = T;
  }

  for (T = 0; C; C = N) {
    N = C->Next;
    C->Next = T;
    T = C;
  }

  free(D);
  return T;
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List