From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Damien Mattei Newsgroups: gmane.lisp.guile.user Subject: hidden feature of vector-copy or bug? Date: Sun, 6 Aug 2023 11:13:29 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12944"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sun Aug 06 11:14:15 2023 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qSZq1-0003Bk-No for guile-user@m.gmane-mx.org; Sun, 06 Aug 2023 11:14:13 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qSZpa-0003Fx-5Y; Sun, 06 Aug 2023 05:13:46 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qSZpY-0003Fk-LT for guile-user@gnu.org; Sun, 06 Aug 2023 05:13:44 -0400 Original-Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qSZpW-00073Z-PS for guile-user@gnu.org; Sun, 06 Aug 2023 05:13:44 -0400 Original-Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-5232bb5e47bso1058524a12.2 for ; Sun, 06 Aug 2023 02:13:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691313221; x=1691918021; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=azgESy1lNJ6ETRhUgsc2QKn4UZR5w2AAcmzIt0/MFbU=; b=As6Dfpe3c+EMTHRDLtdEVg9/lfPMckhJH0xetJllHyK3Yw8Sfyjn1qsowYol5zpITn QW5gUafm2wwtkuiVH4ywWcAGQIah3nzfkUdeQQyGvqOmAA4mVd78jaC+F5zkrslXuNsK 0RjOcfo+GjLmbVsHPyuD8RqN4Glv5pu33jgP0XxaZEtWwFGxM3Weox1M1RMSTA96oTOk hsVyl1Zu/ayVbzbwMetu23tikU4HcJUV1Sd75IP25RFvwhWhdnXlC/WodTnJ0xpPvx3z 1G5Z5CowyABy/VuJJ5Qe/5RBjuJoucE6o/m1AF/ZpcCk/6kKYa31UCLWa3tynuX8Acs2 l5jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691313221; x=1691918021; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=azgESy1lNJ6ETRhUgsc2QKn4UZR5w2AAcmzIt0/MFbU=; b=RCauqc2Yyl4y6oWFauNgavdJJ+Iqq6xo/fQmShUmSf7WMAg1Vby+Eimgd2TXShCudx Lj6dCdmJ+ZfjvUVTUgUXGpH99E61wwfiCkX64M9piWEpPgOLt5QBFWMLTJrDpMwNH5G+ 8uwaJcoxuObx8d5lcpscTPPIfAcYKBEaQPHRZ8hfPRHZQ788v7Bm8V1uoBijBuXW4K+n DsdYmPeacIVIs3XkQDC3X/E3WyD5axn6h/upJUvfXUc8mxmJp4CId12jDbl+/pJTwMM+ OmG9r+oq7ljLx/sdJZtS4dGUJ1+KcfFlv24HVqTcVsL694pXFr2qfqRxgFPtutmOGo+c 971A== X-Gm-Message-State: AOJu0YyLhfkm0it/KPgKBsBbXDq5RrE80Ami6NFJ8ivvCdA0wzqk6nY8 k9Om2LWPsDXWyVHEky7vInD9+5Ny3tpUtnIRjfxeRcQN6uU= X-Google-Smtp-Source: AGHT+IGXwAAUHVE1SvGA8Z0nAPZVHP2yfP6fwlZu6+xPieEA8vmUTMO+LaUQHfueXXpg52C1mWemury3uEsatUTK/lM= X-Received: by 2002:aa7:d697:0:b0:523:18db:e3ab with SMTP id d23-20020aa7d697000000b0052318dbe3abmr5123322edr.39.1691313220734; Sun, 06 Aug 2023 02:13:40 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::534; envelope-from=damien.mattei@gmail.com; helo=mail-ed1-x534.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:19129 Archived-At: hello, i'm maintaining and developing some code i wrote which is using something is a hidden feature or bug in vector-copy? here is the code but there no need to understand it, the problem is explained after ;; scheme@(guile-user)> (define gva (growable-vector 1 2 3 4 5)) ;; scheme@(guile-user)> (define gva2 (growable-vector-resize gva 8)) ;; growable-vector-resize : new-vector :#(1 2 3 4 5 # # #) ;; scheme@(guile-user)> (describe gva2) ;; #< 10394d640> is an instance of class ;; Slots are: ;; v = #(1 2 3 4 5 # # #) (define-method (growable-vector-resize (gv ) (new-size )) ;; fill unspecified (define actual-size (vector-length gv)) (define old-vector (growable-vector-v gv)) (define new-vector (vector-copy old-vector 0 new-size)) ;;(display "growable-vector-resize : new-vector :") (display new-vector) (newline) (growable-vector-set-v! gv new-vector)) it seems that vector-copy when given a end-index greater than the length of vector to copy does not return an error but create a new vector of the good size indeed: scheme@(guile-user)> (define v (make-vector 7 1) ) scheme@(guile-user)> v $2 = #(1 1 1 1 1 1 1) scheme@(guile-user)> (vector-copy v) $3 = #(1 1 1 1 1 1 1) scheme@(guile-user)> (vector-copy v 0 10) $4 = #(1 1 1 1 1 1 1 # # #) here 10 is greater than (length v) but it works and return: #(1 1 1 1 1 1 1 # # #) but the doc does not specify that: "Scheme Procedure: vector-copy vec [start [end]]C Function: scm_vector_copy (vec) Returns a freshly allocated vector containing the elements of vec in the range [start ... end). start defaults to 0 and end defaults to the length of vec." by default end is length of vec, so if i specify an end greater than length of vec should it not be normal to return an error? Damien