Some other ASL requests that have weighed heavily on my mind for some time now. Usually after banging my head on the wall, I'd type up a big ol' write up of my grievances, then by the time my frustration's died down I'd realize it's more rant than request and delete it. This time it's a good night's sleep after, so hopefully I can articulate a good post
Here's an example of what I wrote last night trying to get a small matter accomplished:
ASL Snippet
if($he_sharedPoints[$he_Point[$curHEString2[$j]]].x != -1.0)
{
if ($he_Pair1[$he_EdgeIndex[$fToInt($he_sharedPoints[$he_Point[$curHEString2[$j]]].x)]] != -1)
$feature_neighbors[$he_Pair1[$he_EdgeIndex[$fToInt($he_sharedPoints[$he_Point[$curHEString2[$j]]].x)]]] = 1;
if ($he_Pair2[$he_EdgeIndex[$fToInt($he_sharedPoints[$he_Point[$curHEString2[$j]]].x)]] != -1)
$feature_neighbors[$he_Pair2[$he_EdgeIndex[$fToInt($he_sharedPoints[$he_Point[$curHEString2[$j]]].x)]]] = 1;
if($he_sharedPoints[$he_Point[$curHEString2[$j]]].y != -1.0)
{
if ($he_Pair1[$he_EdgeIndex[$fToInt($he_sharedPoints[$he_Point[$curHEString2[$j]]].y)]] != -1)
$feature_neighbors[$he_Pair1[$he_EdgeIndex[$fToInt($he_sharedPoints[$he_Point[$curHEString2[$j]]].y)]]] = 1;
if ($he_Pair2[$he_EdgeIndex[$fToInt($he_sharedPoints[$he_Point[$curHEString2[$j]]].y)]] != -1)
$feature_neighbors[$he_Pair2[$he_EdgeIndex[$fToInt($he_sharedPoints[$he_Point[$curHEString2[$j]]].y)]]] = 1;
if($he_sharedPoints[$he_Point[$curHEString2[$j]]].z != -1.0)
{
if ($he_Pair1[$he_EdgeIndex[$fToInt($he_sharedPoints[$he_Point[$curHEString2[$j]]].z)]] != -1)
$feature_neighbors[$he_Pair1[$he_EdgeIndex[$fToInt($he_sharedPoints[$he_Point[$curHEString2[$j]]].z)]]] = 1;
if ($he_Pair2[$he_EdgeIndex[$fToInt($he_sharedPoints[$he_Point[$curHEString2[$j]]].z)]] != -1)
$feature_neighbors[$he_Pair2[$he_EdgeIndex[$fToInt($he_sharedPoints[$he_Point[$curHEString2[$j]]].z)]]] = 1;
if($he_sharedPoints[$he_Point[$curHEString2[$j]]].w != -1.0)
{
if ($he_Pair1[$he_EdgeIndex[$fToInt($he_sharedPoints[$he_Point[$curHEString2[$j]]].w)]] != -1)
$feature_neighbors[$he_Pair1[$he_EdgeIndex[$fToInt($he_sharedPoints[$he_Point[$curHEString2[$j]]].w)]]] = 1;
if ($he_Pair2[$he_EdgeIndex[$fToInt($he_sharedPoints[$he_Point[$curHEString2[$j]]].w)]] != -1)
$feature_neighbors[$he_Pair2[$he_EdgeIndex[$fToInt($he_sharedPoints[$he_Point[$curHEString2[$j]]].w)]]] = 1;
}
}
}
}
I built those lines slowly while it made sense, but now looking at it it'll take me a few minutes to actually figure out what's linking to where, and I'm the one that wrote it! There's also no simpler method that I could think of. To help myself out, I write nearly as many comments as lines of code, but still I would hate life if I had to come back to this code even a week later when it's not fresh in my mind. It's also only a small portion of the entire script, which I'm not going to share because it'd cause nightmares to all present.
Arrays in functions: Passing arrays as parameters, and returning arrays from functions. Without this, I have to create arrays beforehand outside of the $main function so that the function can fill in arrays. This is extremely counter intuitive, and hard to organize when multiple functions need to output arrays multiple times for the main function or between other functions.
Recursion: It's incredibly difficult converting algorithms that require recursion into non-recursive functions. A lot of 3D-related algorithms rely on binary trees/linked lists, and making non-recursive traversal functions (especially without custom data structures as requested below) is a stack of headaches rolled into one. I have to create stacks and counters and do convoluted orders of operations to try and cope with it.
Custom data structures: I'm not asking for anything super complicated like full-featured object definition. I just want to be able to make my own data structure out of the data types already available. I could make linked lists without having to create a dozen arrays with weird convoluted relationships to each other passing indices as values to be indices for other arrays.
An example of how it'd look creating a new data structure could be something like:
!datatype half-edge (int id, int next, int prev, point3 point, int edgeindex, int opposite);
! indicates it's compiled first before the rest of the script, and needs to be asserted outside of the $main function. Then to use the half-edge data type, declare it like any other variable:
half-edge $HE[1];
To assign the values, two methods can be used.
$HE[0] = (0, 1, -1, (0,0,0), 85, 23); // Can also have variables passed as values
$HE[0].id = 0;
$HE[0].next = 1;
$HE[0].prev= -1;
$HE[0].point = (0,0,0);
$HE[0].edgeindex = 85;
$HE[0].opposite = 23;
It'd be useful to also be able to use custom data types within custom data types. For example a custom data type vertex:
!datatype vertex (int id, point3 loc);
vertex $v;
Can be used in half-edge:
!datatype half-edge (int id, int next, int prev, vertex point, int edgeindex, int opposite);
Writing to it can look like this:
$HE[0].point.id = 1;
$HE[0].point.loc =(0,0,0);
Pointers: Same * and & operators/behavior as in C++, would aid the use of custom data types, binary trees, linked lists...
Matrices: I'm already fairly deficient when it comes to 3D math, so I won't go into much detail here. Some means to make matrices Nxn size, and functions to perform operations on these.
Type conversion. toInt and toFloat functions for strings (like toInt("123.45") returns 123 and toFloat("123.45") returns 123.45. I made my own functions in ASL to do this but it'd obviously be much more efficient if this was built-in.
toString for ints and floats (yes there's PrintToString, this would basically be a simplified macro of that).
Automatic type conversion between ints and floats (for example $array[1.466] automatically converts down to $array[1]).
Adding two multiple strings appends them together in the order they appear. Example: $var = "Hello" + " " + "there" + ", " + "everyone!"; is a lot simpler than doing $var = PrintToString("%s%s%s%s%s", "Hello", " ", "there", ", ", "everyone!");
[Edit] Obviously, most of these requests are things found in regular programming languages. If instead an API/dll extension system was being worked on, I really couldn't care less about these requests and just wait for that to save myself all the headache