Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

This is the primary module for my APL interpreter. The general idea is motivated by my two Stack OverflowStack Overflow questionsquestions, but the details I fear are easy to get wrong and I suspect there are a few corners that my eyes simply don't observe critically since they have the authority of having lain in the file so long without change.

This is the primary module for my APL interpreter. The general idea is motivated by my two Stack Overflow questions, but the details I fear are easy to get wrong and I suspect there are a few corners that my eyes simply don't observe critically since they have the authority of having lain in the file so long without change.

This is the primary module for my APL interpreter. The general idea is motivated by my two Stack Overflow questions, but the details I fear are easy to get wrong and I suspect there are a few corners that my eyes simply don't observe critically since they have the authority of having lain in the file so long without change.

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

The data elements here are always ints. "Everything is an int" was a guiding mantra in designing the whole project. So, via a tag/value encoding (comp.lang.c code review thread newer code reviewnewer code review), values of many types can be embedded in these arrays. They're not generic in the normal C programming sense of the word. But by operating over ints, it achieves genericity by virtue of the way it is used by the other modules.

Additional related modules have been posted for review herehere and in comp.lang.c.

The data elements here are always ints. "Everything is an int" was a guiding mantra in designing the whole project. So, via a tag/value encoding (comp.lang.c code review thread newer code review), values of many types can be embedded in these arrays. They're not generic in the normal C programming sense of the word. But by operating over ints, it achieves genericity by virtue of the way it is used by the other modules.

Additional related modules have been posted for review here and in comp.lang.c.

The data elements here are always ints. "Everything is an int" was a guiding mantra in designing the whole project. So, via a tag/value encoding (comp.lang.c code review thread newer code review), values of many types can be embedded in these arrays. They're not generic in the normal C programming sense of the word. But by operating over ints, it achieves genericity by virtue of the way it is used by the other modules.

Additional related modules have been posted for review here and in comp.lang.c.

change number in example so you can see it in the call
Source Link
luser droog
  • 2k
  • 14
  • 31

And my most recent augmentation is function-type arrays, which do not store all their declared data, but generate it as a function of the index. Thus, a [2][3][4] array of the constant 142 can be created without actually storing 24 142s in memory.

array b = array_new_function(3, (int[]){2,3,4},
    (int[]){1,142}, 2, constant);

*elem() for each index will return 142. An array which simply consists of sequential integers 0..n can be created with the j_vector function-type array. And a considerable degree of constant-folding can be done by modifying the elements of the ->weight member array and the cons member. Indeed the values of any polynomial can be enumerated by creation of suitable dimension and weight parameters.

And my most recent augmentation is function-type arrays, which do not store all their declared data, but generate it as a function of the index. Thus, a [2][3][4] array of the constant 1 can be created without actually storing 24 1s in memory.

array b = array_new_function(3, (int[]){2,3,4},
    (int[]){1,1}, 2, constant);

*elem() for each index will return 1. An array which simply consists of sequential integers 0..n can be created with the j_vector function-type array. And a considerable degree of constant-folding can be done by modifying the elements of the ->weight member array and the cons member. Indeed the values of any polynomial can be enumerated by creation of suitable dimension and weight parameters.

And my most recent augmentation is function-type arrays, which do not store all their declared data, but generate it as a function of the index. Thus, a [2][3][4] array of the constant 42 can be created without actually storing 24 42s in memory.

array b = array_new_function(3, (int[]){2,3,4},
    (int[]){1,42}, 2, constant);

*elem() for each index will return 42. An array which simply consists of sequential integers 0..n can be created with the j_vector function-type array. And a considerable degree of constant-folding can be done by modifying the elements of the ->weight member array and the cons member. Indeed the values of any polynomial can be enumerated by creation of suitable dimension and weight parameters.

link to new encoding review
Source Link
luser droog
  • 2k
  • 14
  • 31
Loading
edited tags
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237
Loading
improve title (?)
Link
luser droog
  • 2k
  • 14
  • 31
Loading
add examples of constant folding
Source Link
luser droog
  • 2k
  • 14
  • 31
Loading
typo
Source Link
luser droog
  • 2k
  • 14
  • 31
Loading
specific commit in github links
Source Link
luser droog
  • 2k
  • 14
  • 31
Loading
elem is not a macro
Source Link
luser droog
  • 2k
  • 14
  • 31
Loading
elem is not a macro. repo link. change clc link to more interesting thread
Source Link
luser droog
  • 2k
  • 14
  • 31
Loading
elem is not a macro
Source Link
luser droog
  • 2k
  • 14
  • 31
Loading
one other #included file
Source Link
luser droog
  • 2k
  • 14
  • 31
Loading
deleted 10 characters in body
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237
Loading
Source Link
luser droog
  • 2k
  • 14
  • 31
Loading