When children 
are brought up speaking two languages, they often go through a stage of 'mixing' where they appear to be unable to separate their languages.  For instance, a Welsh word might be inserted into an English sentence:  As an example, when I first realised the implications of death, my parents told me that I cried and said "I don't want to go into the 
pridd" (earth, dirt).
Several theories have been put forward to explain this.  Firstly, I may simply not have known the word for 'dirt', and had to rely on a word in another language.  Back then, Welsh was probably my stronger language, so this would be an example of mixing into my weaker language.  Alternatively, I had not yet learned to tell the difference properly between Welsh and English.
However, both my parents speak Welsh and both languages are used, probably with quite a lot of mixing.  Therefore, I may have known the English word, and been aware that I was mixing, but I knew that using a bilingual code was permissible, given my interlocutors.
Indeed, 
Montanari (2008) finds that the child she studies mixes some words even when they know the word in the language of context.  Does this suggest, then, that the child simply didn't know which words belonged to which language?  I argue that this isn't necessarily the case.
Adults mix their languages for many reasons.  In fact, it's often difficult to decide which language a word belongs to without a lot of context (e.g. 'zeitgeist').  Let's forget about languages for a minute and ask 'to what extent has the child acquired the 
communicative code of its parents'?  By this, I mean how closely does the child's output mirror the parent's input?
To do this, let's look at 
Quay's (2008) study of a trilingual child.   Japanese is the language of the environment,  the   father   is   strongest   in   English   and   also   speaks   Japanese   and   the   mother strongest in Chinese and also speaks English and Japanese.  Weekly recordings were made from 1;10  to  2;4  years.  The  utterances   of   both  the  child  and  the  parents   were  coded  along  with  the addressee.  The summary of the data is very detailed - containing the proportions of mixing between any two people in Japanese/English, Japanese/Chinese, Chinese/English and Japanese/Chinese/English.
Let's model the child's mixing proportions as a function of the parent's mixing proportions.      Each cell in the table below contains the correlation between the model’s predictions and the child’s actual mixing proportions.  The first two models use the mother and father’s data separately. The third model is an additive model which combines the parents’ utterances and the fourth uses the difference between the parents’ mixed utterance types. The difference model was provided as a conceivable, but unlikely model. The correlations in the first column correspond to a model using the total input, whereas the last two columns correspond to a model using only utterances directed to the child (direct) and utterances directed to the other parent (indirect).
Although the mother spends more time with the child than the father, the total mixing behaviour of the child is equally predicted by the mother and the father.  However, the best model is an additive model of the direct utterances to the child.  That is, the child's output is closest to a model which tries to imitate the mixing behaviour of both parents.
Interestingly, the highest correlation between the mixing proportions is between the parents (0.999), which is nearly perfect. Perhaps, then, the child is simply trying to acquire the adult’s mixing strategies or 'Code'.
We can look at the data in more detail by calculating the correlations between mixing proportions for each interlocutor separately:
When addressing the mother, the child's mixing  proportions  reflect  the  mother’s  total  mixing  proportions  better  than  the  father’s  and vice versa,  indicating pragmatic differentiation  to each parents’  mixing.   When addressing the father,  the  child’s  mixing  proportions  reflect  the  mother’s  indirect  input.   This  could  indicate that the child is mimicking the mother’s interaction with the father.  The opposite isn't true, but any mimicry may be masked since the child spends so much time alone with the mother.
These two analyses  conclude that  the child’s  mixing  reflects  the mixing  of  the parents  from a very young age.  Modelling allows us to gain extra insights on the potential learning mechanism for the child, but it relies on detailed data, as in Quay (2008).  The model could be taken further to include considerations of location, the societal status of each language and the parent's tactics (Negative evidence, implicit allowance of mixing, teaching of translation equivalents etc.).
Now for the ambitious, unfounded part:  Considering a communicative code, there may  be no qualatative difference between mono- and bi-lingual language acquisition.  How,   then,   do   bilinguals   select   words?     One   possible   solution   is   to   use   a   sort   of   Bayesian probability   distribution   over   the   linguistic,   social   and   pragmatic   contexts   for   each   word   that represents   the   best   estimation   of  when  to   use   a   word.     If   a   mapping   between   words   and pragmatic   and   social   contexts   is   acquired,   a   discrete   mapping   between  words   and  ‘languages’ becomes irrelevant.     This approach  works  equally well  for acquiring  one  ‘language’,  or  several levels   of   tone   or   dialect.
In   this   sense,  the   ‘remarkable’   ability   to   keep   languages   separate (Costa & Santesteban, 2004) seems less remarkable and less specific to bilinguals:  We don’t find it remarkable that an adult refrains from using terms of endearment during a boardroom speech.
This   approach   would   be   extended   to   syntactic   acquisition   by   assuming   that,   as   the   mapping between  words   and  meanings   developed,   strings   of   words   themselves   became  a  context   which was encodable in the probability distributions of words.  This   is   essentially   a   constructivist   approach   to   bilingual   acquisition:  Before  linguistic acquisition,  infants first  learn  an  embodied perceptual  ‘language’  –  an  iconic mapping between form   and   meaning   –   which   allows   them   to   relate   structure   in   the   world   to   an   interaction between   sensory   and   motor   activity.     The   mapping   between   structure   in   the   world   and symbolic,  linguistic representations  would build itself  on top of this  system  in the same way as syntactic (Bernardini & Schlyter) and lexical (Nicoladis & Secco) acquisition can build on pre-existing   structures.   
Following   from  this,   the   ‘difficult’   bit   of   language   acquisition   is   not   the segmentation   of   strings   into   words   or   words   into   lexicons,   but   the   initial   segmentation   of   the world   into   functional   concepts.     The   development   of   this   more   fundamental   understanding   of the  world  may  be  an  additional  factor  in  the  qualitative  differences  between  mixing  in  children and adults.