logs archiveBotHelp.net / Freenode / #ada / 2015 / July / 21 / 4
Lucretia
pasting sh*t is bad
:D
avoiding tagged types?
Visaoni
strictly speaking, I shouldn't /need/ them
everythign is known at compile time
and it's not like I have any desire to make a collection of a variety of prngs
and, given one of the nice advantages of the methods is that it'd be pretty reasonable to throw on a micro, I wanted to avoid tags
Lucretia
sounds like a good project, actually
as long as it's generic as well, like the standard Ada one. tht way we can have random enumerations as well :D
charlie5
are tags so pricy ? ... only an extra pointer per object, really
Visaoni
naturally
Lucretia
the tag is not a pointer, iirc
Visaoni
discrete types are really rather interchangable
Lucretia
it's an id
Visaoni
Pos, Val, who cares if it's an enum or an integer :)
Lucretia
(Action) doesn't actually know how dispatching in Ada is implemented, but afaict, not a vtable like in other languages
just saying, basic tagged types without dispatching should be fine on a micro
charlie5
i thought the tag was a pointer to the classes 'dispatch table' (forget proper name)
Lucretia
(Action) should look into it
charlie5
yeah, vtable, that's it :)
essentially just a table of pointers to functions, i think
a derived class overriding function replaces the parents function in the appropriate slot in the new classes vtable
if that makes any sort of sense :)
Lucretia
that's how it's done in C++ and oberon
not sure for Ada
Visaoni
but yeah, also wanted to change the interface to things a bit... no reason for the generator to have a baked-in result type, and some kind of bounded_random would be good
don't know why a bounded_random isn't in by default... the logic is no different than Random, it just isn't available to users to do it, forcing them to do it poorly or duplicate the code
(Action) would kill for primitive generic subprograms
but alas
and some kind of generic parameter that is considered static and would be forced to be known at compile time
can interfaces be generic? in the sense that the interface provides a generic ot be instantiated
Lucretia
they can be parameters to a generic
Visaoni
bleh
is there really no way to "give" a generic subprogram to multiple types?
the best I've come up with is have a package that takes a partial generator, makes a new type from it, and provides the generic itself
it basically works, unless you want to do something like take a generic generator...
(the new type it created being the complete generator)
Lucretia
you can pass types into the geneeric
Visaoni
yes, but the only type the user would see would come from inside of an instantiated generic package
that package only being used to add a subprogram
Lucretia
thats the only way
Visaoni
figured as much
charlie5
(Action) refrains from exposing his generics ignorance
oh ... i just did :(
Visaoni
it seems like such an oversight
I don't see why generic subprograms are so special as to be impossible to inherit
charlie5
yeah, maybe ask on cla ... i think more ppl there are more familiar with generics than most ppl here
Lucretia
again, you can pass in a subprogram parameter
with procedure ...
with function ...
Visaoni
I'm not sure how that helps?
Lucretia
whether the parameter can have varying types, I can't see why not
(Action) isn't really sure waht you want
charlie5
it's hard to visualise w/o the code ... any chance of making it public ?
darkestkhan
Lucretia: dispatching in Ada... you pay price only if you actually dispatch...
Lucretia
yes
Visaoni
charlie5: things are a bit of a mess at the moment... had a bit of a period when I tried a bunch of things rather shortly and just made a total mess of things
what I want can be easily described though
gimme a sec
(well, this /one/ thing I want)
charlie5
hok :) ... i'm not far off bed myself ... if you can post a link, i'll try to look tomorrow
Visaoni
https://pastebin.mozilla.org/8840121
charlie5
hmm
don''t quite get why do you need a child_generator ?
Visaoni
reasons :)
is very needed
charlie5
if i grok it right ... the generic will take a base_generator (say somthing that rnages from 0..1) and convert it to the range of the discrete type ?
s/convert/map/
Visaoni
basically
the PCG thing has several different types of generator available, depending on some of the features you want.
charlie5
might you want something like this then ? ...
function Random( Gen : Base_Generator'Class ) return Result_Type;
so Random function can take any kind of child Generator ?
as i said, it's to suggest w/o really knowing the full code context
<... it's hard to ...>
Visaoni
yeah, works great with tags :)
charlie5
ah :)
Visaoni
it's not that this problem is impossible to solve without tags either. you can have Random take generic generator type too, which is basically what I've been thinking of doing myself behind the scenes
charlie5
ok, how about ...
generic
type Generator is private;
type Result_Type is (<>);
function Random( Gen : Generator ) return Result_Type;
.
except
that you would need to know what you can do with a generator, so you may need to pass in the functions you need to perform on Generator also as generic params
are there many ?
Visaoni
no, there are not
doesn't matter though
if you swap out
type Generator is new Base_Generator;
well, swap in
Natacha
generic type Generator is private; type Result_Type is (<>); with function Actual_Random (Gen : Generator) return Result_Type; function Random (Gen : Generator) return Result_Type;
fixed \o/
Visaoni
ha :)
yeah
this is basically what I've been thinking of doing for the user, behind the scenes. wrap that up in a package, blah blah
but, that fu*ks up the ability of the user to accept a generic generator type, so...
maybe I just have to give in and make the user pass the generator type in themselves
it rather offends my sensibilities
« prev 1 2 3 4 5 6 next »