Would this work?
DEFINE_PRIMITIVE ("STRING-HEAD!", Prim_set_string_maximum_length, 2, 2, 0)
{
PRIMITIVE_HEADER (2);
CHECK_ARG (1, STRING_P);
{
SCHEME_OBJECT string = (ARG_REF (1));
long length
= (arg_index_integer (2, ((MAXIMUM_STRING_LENGTH (string)) + 1)));
if (length < (STRING_LENGTH (string)))
SET_STRING_LENGTH (string, length);
MEMORY_SET
(string,
STRING_HEADER,
(MAKE_OBJECT
(TC_MANIFEST_NM_VECTOR, ((BYTES_TO_WORDS (length + 1)) + 1))));
PRIMITIVE_RETURN (string);
}
}
On Sat, Sep 5, 2009 at 4:01 PM, Joe Marshall<[email protected]> wrote:
> I can write it, but I can't test it.
>
> On Sat, Sep 5, 2009 at 3:51 PM, Chris Hanson<[email protected]> wrote:
>> Agreed, though it should be called STRING-HEAD! and take only two arguments.
>>
>> On Sat, Sep 5, 2009 at 3:20 PM, Taylor R Campbell<[email protected]> wrote:
>>> Rather than changing each instance of SET-STRING-MAXIMUM-LENGTH! to
>>> check whether it worked and to use SUBSTRING if it failed, perhaps it
>>> would be better to add a SUBSTRING! procedure to do this.
>>>
>>>
>>> _______________________________________________
>>> MIT-Scheme-devel mailing list
>>> [email protected]
>>> http://lists.gnu.org/mailman/listinfo/mit-scheme-devel
>>>
>>
>>
>> _______________________________________________
>> MIT-Scheme-devel mailing list
>> [email protected]
>> http://lists.gnu.org/mailman/listinfo/mit-scheme-devel
>>
>
>
>
> --
> ~jrm
>
--
~jrm
_______________________________________________
MIT-Scheme-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/mit-scheme-devel