3 days ago

https://www.youtube.com/watch?v=s_1OG9GwyOw

https://github.com/burner/Darser/blob/dbe6269aba4abce3b0c6ac07d00da6c86ee7c758/presentation/example.d#L150

struct Parser {
	Document[] documents;
	Definitions[] definitionss;
	Definition[] definitions;
	OperationDefinition[] operationDefinitions;
	SelectionSet[] selectionSets;
	OperationType[] operationTypes;
	Selections[] selectionss;
	Selection[] selections;
	FragmentSpread[] fragmentSpreads;
	InlineFragment[] inlineFragments;
	Field[] fields;
	FieldName[] fieldNames;
	Arguments[] argumentss;
	ArgumentList[] argumentLists;
	Argument[] arguments;
	FragmentDefinition[] fragmentDefinitions;
	Directives[] directivess;
	Directive[] directives;
	VariableDefinitions[] variableDefinitionss;
	VariableDefinitionList[] variableDefinitionLists;
	VariableDefinition[] variableDefinitions;
	Variable[] variables;
	DefaultValue[] defaultValues;
	ValueOrVariable[] valueOrVariables;
	Value[] values;
	Type[] types;

this isnt quite right for soa

this is adding an extra layer of indirection

if you have some n^2 iteration lets say

foreach(i;0..selections.length){
foreach(j;0..fields.length){
  ref selection()=>selections[i];
  ref field()=>fields[j];
  foo(selection,fields);
}}

The pointer math isnt being automagicly done compile time by the optimizer in the way this would:

struct Parser(int length){
  Selection[length] selections;
  Field[length] fields;
  ...

(it cant be fully optimized at compile time selections[3].offset-fields[3].offset changes at runtime)

in the original code theres extra indirection, a bounds check that may not disappear(because *.length== all other *.length is not generteed), etc.

Ive gave up on aosoa, it probaly needs compiler support, but thats the thoery for a reason; I think lib level we should have a different target for making some bread and butter dod patterns