Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Variadic functions questions
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ilya Martynov  
View profile  
 More options Mar 22 2004, 5:48 am
Newsgroups: perl.perl6.internals
From: i...@iponweb.net (Ilya Martynov)
Date: Mon, 22 Mar 2004 12:44:47 +0300
Local: Mon, Mar 22 2004 4:44 am
Subject: Variadic functions questions

Hello all,

1) First question is how to tell if variadic function recieved 11 or
   12 or more params (for simplicity let's suppose that we use only
   pmc parameters).

According calling conventions (pdd03) first 11 params end up in P5-P15
registers and leftover goes into array in P3. The problem is that
there is no indication (unless I'm missing something) if function was
called with more than 11 params other than register P3 being
initialized with some array PMC. But it may be as well that function
was called with just 11 params and P3 contains some array by accident
(it could be for example some array from previous sub call).

2) Second question if there is an op to access registers by their
   number (it is quite troublesome to write code to retrieve
   parameters in variadic function from P5-P15 registeres without such
   op).

ops/set.ops has setp_ind op which allows to write to register by its
number but it seems there is no op to read register by its number.

3) Not really a question but a feature request for IMCC to provide
   some support for variadic functions to avoid writing same code
   again and again to read parameters of variadic function from either
   P5-P15 registers or from array in P3 register as necessary. Not
   sure about syntax though. It could look for example like this:

# calculates sum of all parameters
.sub _sum
        new $P1, .PerlInt
        $P1 = 0
        # generates code which sets $I1 to a number of parameters
        $I1 = .param_num
loop:
        if $I1 == 0 goto return
        # retrieves a parameter by its number
        $P2 = .param($I1)
        add $P1, $P2
        dec $I1
        goto loop
return:
        .pcc_begin_return
        .return $P1
        .pcc_end_return
.end

--
Ilya Martynov,  i...@iponweb.net
CTO IPonWEB (UK) Ltd
Quality Perl Programming and Unix Support
UK managed @ offshore prices - http://www.iponweb.net
Personal website - http://martynov.org


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.