[m-dev.] Re: quickcheck

Mark Anthony BROWN dougl at cs.mu.OZ.AU
Fri Feb 16 14:28:17 AEDT 2001


Xiao Chun Simon MEI writes:
> 
> > +Default for string is rand_string/2, each element is generated by 
> > +rand_char/2. 
> > +0.9^0 * 0.1  chance being string length == 0
> > +0.9^1 * 0.1  chance being string length == 1
> > +0.9^2 * 0.1  chance being string length == 2 
> > +...etc...    
> > +so the average string length is Sum(0.1* 0.9^N * N) where N <- {0,
> infinity} 
> 
> >> So the average string length is 10?
> 
> Is it ? I couldn't work it out, don't remember much of my 2nd year maths.
> If u r sure, i will rely on you and put in Length=10.

I'm not completely sure, so you should check that out yourself.  The main
point is that you should put the number here instead of the formula (or
you could put both, I suppose).

Anyone else care to simplify that formula?

> 
> ----------------------------------------------------
> 
> > +Specific Frequency changes the a term's default frequency (which is
> > evenly spread) 
> 
> >> s/the a term's/a type's/
> 
> hmm... SF describes how ONE variable should be generated, it doesn't 
> say how should a certain type be generated. Of course that variable will
> have a type, so I am not sure which would be the correct word.

On second thoughts, "term" was probably right.  So you should just remove
the "the".

> 
> -----------------------------------------------------
> 
> > +<P>
> > +<table border=0 width=100% bgcolor=#eeeee0><tr><td><pre>
> > +Let's try to describe Company_W's bullet, Bullet is discrimated union,
> > so the right format is :
> 
> >> In the other tutorials, a table like this is used to display Mercury
> >> code, but this table contains a written example.  This is a bit
> >> inconsistent -- I think you should display this example normally (i.e.
> >> not in a table).
> 
> I put them in a table because i thought that part about Specific Frequency
> is tough to understand. I've changed the table color ; is that ok ?

That should be OK.  Using that style for the Mercury code looks good, IMHO,
but using the same style for some non-code spoils the consistency a bit.

> 
> -------------------------------------------------------------
> 
> > +     [ frequency_black, frequency_white ] 
> > +
> > +     :- type frequency       = {int, list(list(frequency))}.
> > +     frequency_black         = {100, ...something_black...}
> > +     frequency_white         = {0,   ...something_white...}
> > +
> > +something_black has format list(list(frequency)), and should describe
> >  the argument(s) of black/0.
> > +black/0 has no argument, thus the list is [], likewise for white/0
> > +(if instead of black/0, it's black/4 then the list would be length 4.
> > OR [] when you get sick of 
> > +specifying frequency and just want to use the default)
> 
> >> It would be worth making more of a point of this way of using defaults,
> >> rather than just as a remark in parentheses.
> 
> Do u mean just take the brackets off ? or do u mean make an new example
> for such cases ?

I mean you should explain more about getting back to the default, because I
think it is an important point.  You can make a new example for this if
you wish.

> 
> -------------------------------------
> 
> > qcheck(qcheck__f(prop2), "bullet fight", 10000, [[],B,W], []).
> >  [[],B,W]
> > The 1st element [] of type list(frequency) is for type int, which
> > doesn't make sense, since type int is not a discriminated union. That [] 
> > will be ignore when generating int, but it's presence is required.
>  
> >> I think that could be phrased better.  For example:
> >>
> >>        The first argument of prop2/3 is of type int, so we wish to use
> >>        the default rather than supply a specific frequency.  We
> >>        therefore pass [] as the first element of the list, which tells
> >>        qcheck to use the default generator for that type.
> 
> well, the [] does not tell qcheck to do any thing, one can replace
> that [] with anything ( as long as it's the correct type to shut up the
> compiler check), and qcheck will run exactly the same.
> 
> It's only use is to fill the space, 
> If instead of [ [], B, W ] , the user pass  [ B, W ] to qcheck/5, then
> qcheck will run as if it's given [ B, W, [] ]
> 
> your paragraph sounds like if [] has special meaning, which isn't entirely
> true. ( I could write a check, and forces user to enter [] for non
> discriminated unions)

That's probably a good idea, but not necessary.

However, I did misunderstand the precise role '[]' was playing, so I think
you need to explain it more.

> And also do you want me to post the current changes (Tute1-6) for review ?
> or wait until you've reviewed all the tutes?
> 

The rest of the review is coming soon.  I also have some comments on the
overall structure of the tutes (the order in which ideas are introduced,
etc).  I'll let you know when I'm ready for another diff.

Cheers,
Mark.

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list