Skip to content

Instantly share code, notes, and snippets.

@Lucretia
Created February 18, 2025 21:06
Show Gist options
  • Select an option

  • Save Lucretia/a331ca344f2644df24e64810236cee9d to your computer and use it in GitHub Desktop.

Select an option

Save Lucretia/a331ca344f2644df24e64810236cee9d to your computer and use it in GitHub Desktop.
------------------------------------------------------------------------------------------------------------------------
-- This source code is subject to the BSD license, see the LICENCE file in the root of this directory.
------------------------------------------------------------------------------------------------------------------------
-- Maths.Stacks
------------------------------------------------------------------------------------------------------------------------
with Ada.Containers.Indefinite_Vectors;
-- with Maths.Matrix4s;
generic
type Element_Type is private;
with function "=" (Left, Right : Element_Type)
return Boolean is <>;
package Maths.Stacks is
type Reference (Matrix : not null access Element_Type) is limited private with
Implicit_Dereference => Matrix;
type Stack is private;
-- procedure Push (Self : in out Stack_Vector.Stack; New_Top : Matrix4s.Matrix4);
-- function Pop (Self : Stack_Vector.Stack) return Matrix4s.Matrix4;
function Top (Self : Stack) return Reference; -- Holder? Reference?
private
-- package M4 renames Maths.Matrix4s;
-- subtype Matrix is M4.Matrix4 (M4.Components);
type Reference (Matrix : not null access Element_Type) is limited null record;
package Stack_Vector is new Ada.Containers.Indefinite_Vectors
(Index_Type => Natural,
Element_Type => Element_Type,
"=" => "=");
-- Element_Type => Matrix,
-- "=" => M4."=");
type Stack is new Stack_Vector.Vector with null record;
end Maths.Stacks;
------------------------------------------------------------------------------------------------------------------------
-- This source code is subject to the BSD license, see the LICENCE file in the root of this directory.
------------------------------------------------------------------------------------------------------------------------
package body Maths.Stacks is
-- procedure Push (Self : in out Stack_Vector.Stack; New_Top : Matrix4s.Matrix4);
-- function Pop (Self : Stack_Vector.Stack) return Matrix4s.Matrix4;
function Top (Self : Stack) return Reference is
begin
return Reference'(Matrix => Self.Reference (Self.First_Index).Element);
-- return R : Reference (Matrix => Self.Reference (Self.First_Index).Element) do
-- null;
-- end return;
end Top;
end Maths.Stacks;
@Lucretia

Copy link
Copy Markdown
Author

maths-stacks.adb:10:07: error: access discriminant in return object would be a dangling reference
maths-stacks.adb:10:35: error: actual for "Container" must be a variable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment