From: "Kjeld H. Mortensen" To: designCPN@daimi.au.dk Date: Fri, 25 Jul 2003 09:45:31 +0200 Subject: Re: (dCPN) Question regarding the use of SML datatypes Dear Martina Friedrich The correspondence to an SML datatypetype in CPN ML is the union type: color INT = int; color STRING = string; color int_or_real = union I:INT + S:STRING; Now you can make places with the colour set inscription int_or_real, and an initial marking of, e.g., 1`I(1) ++ 1`S("test"). I want to mention a very useful function for union colour sets, namely the of_id function. If you declare: color int_or_real = union I:INT + S:STRING declare of_I,of_S; var ior : int_or_real; you can write the following in a guard: [ of_I'int_or_real ior ], assuming you have the ior variable on an input arc. In this example the guard will be true if ior is bound to an I(...) colour and false otherwise, i.e., the transition can only occur is ior is bound to an I(...) colour. Similarly for the function of_S'int_or_real where it will return true if ior is bound to some S(...) colour. I would like to mention another useful trick with pattern expressions on arcs: If you declare var i : INT; then you can also write a pattern as an input arc as: I(i). If you then have an output arc with the inscription i, then a simulation run until no more transitions are enabled will result in the marking 1`S("test") on the input place and 1`1 on the output place -- given the initial marking above. I hope this will get you started using union colour sets. You can also consult the online CPN ML reference manual at: http://www.daimi.au.dk/designCPN/man/ Regards, -- Kjeld H. Mortensen * khm@daimi.au.dk * www.daimi.au.dk/~khm University of Aarhus * Department of Computer Science * Denmark Quoting ma_friedrich@gmx.de: > Dear ladies and gentlemen, > I am a Civil Engineer student and I am working with Design/CPN in the course > of my diploma thesis. > > The following problem occured: > Based on the findings in the literature I tried to construct a variable that > can either have the type of an integer or a string- at the same time. > In SML it is possible to construct the variable as followed > datatype int_or_real = I of int| S of string; > > Now, if I try to construct the same variable in the course of Design, I > cannot tell the program to do so- various problems occur. > Can you help me solving this problem? > > I would be more than grateful, if you could. > Thank you very much in advance. > Martina Friedrich > > --- > [[ Post messages and summary of replies: designCPN@daimi.au.dk > ]] > [[ To (un)subscribe, send "help" to: Majordomo@daimi.au.dk > ]] > [[ The moderator's address: designCPN-owner@daimi.au.dk > ]] > [[ World Wide Web URL: http://www.daimi.au.dk/designCPN/email/ > ]] --- [[ Post messages and summary of replies: designCPN@daimi.au.dk ]] [[ To (un)subscribe, send "help" to: Majordomo@daimi.au.dk ]] [[ The moderator's address: designCPN-owner@daimi.au.dk ]] [[ World Wide Web URL: http://www.daimi.au.dk/designCPN/email/ ]]